XL5: "Argument Not Optional" Using Visual Basic ATP Functions |
In Microsoft Excel, when you use any of the following Analysis ToolPak functions in a Visual Basic module
Argument not optional
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.
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 professionals 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)")
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.
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
Additional query words: addins err msg
Keywords : xlwin
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type :
Technology :
|
Last Reviewed: December 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |