XL5: "Argument Not Optional" Using Visual Basic ATP Functions

Last reviewed: June 23, 1997
Article ID: Q118799
5.00 WINDOWS kbprg kbtool kbcode kbfixlist xlwin

The information in this article applies to:

- Microsoft Excel for Windows, version 5.0

SYMPTOMS

In Microsoft Excel, when you use any of the following Analysis ToolPak functions in a Visual Basic module

   GCD()
   LCM()
   MULTINOMIAL()
   IMPRODUCT()

you may receive the following error message:

   Argument not optional

CAUSE

You receive this error message when you use any of the above functions with less than 29 arguments. This error message indicates that you have omitted a required argument for the function. The functions GCD(), LCM(), MULTINOMIAL(), and IMPRODUCT() should accept from 1 up to 29 arguments to return a value. However, these functions require all 29 arguments.

WORKAROUND

To avoid receiving this error message when you use one of these functions in a Visual Basic procedure, you can use the ExecuteExcel4Macro method to call these functions. To use this method, you must first open or load the Analysis ToolPak add-in, (ANALYSIS.XLL). You can then use the following example to access the LCM() function:

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

   Sub Test()
      Dim x as Integer
      x = Application.ExecuteExcel4Macro("LCM(5,2)")
   End Sub

The following examples use the GCD(), IMPRODUCT(), and MULTINOMIAL() functions using the ExecuteExcel4Macro method:

   x = Application.ExecuteExcel4Macro("GCD(100,5)")

   x = Application.ExecuteExcel4Macro("IMPRODUCT(""8+5i"",""4-3i"")")

   x = Application.ExecuteExcel4Macro("MULTINOMIAL(2,3,4)")

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.

MORE INFORMATION

You can use the functions provided in the Analysis ToolPak-Visual Basic for Applications add-in in a Visual Basic procedure by referencing the add-in file ATPVBAEN.XLA from within your module. For more information about using the Analysis ToolPak functions in a Visual Basic procedure, query on the following words in the Microsoft Knowledge Base:

   atpvbaen.xla and references and functions


KBCategory: kbprg kbtool kbcode kbfixlist
KBSubcategory: xlwin

Additional reference words: 5.00 addins err msg
Keywords : xlwin kbcode kbfixlist kbprg kbtool
Version : 5.00
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.