Hello Gary,
If you are using the word "function" in the sense of an Excel function,
such as the name of one of the many functions in the Excel Solver add-in,
you can replace one function's name with another using the =SUBSTITUTE(...)
function. Check the Excel Help topic on Substitute.
If you are using the word "function" in the sense of a macro you need to
use the Select...Case VBA method. An example would be
Select "Function_Name"
Case "MyFunction1"
Result = MyFunction1(argument1, argument2, ...)
Case "MyFunction2"
Result = MyFunction2(argument_a, argument_b,...)
...
MsgBox"Result is " & Result.
--------------------
From: "Gary Varga" <
[email protected]>
Subject: Executing a function when the name is in a string
Date: Mon, 4 Aug 2003 02:10:35 -0700
I have a function name in a string and would like to
execute the function using the string e.g.
'A number of functions are defined
Function X() as String
X = "Called"
End Function
...
'Get the function name
Dim function_name as String
function_name = "X"
...
'Execute the function
'NOTE: The crux is that I need the equivalent of the line
below
Call function_name
Many thanks,
Gary
Regards,
Chris Jensen[MSFT]
This posting is provided “AS IS” with no warranties, and confers no rights.
“Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
http://www.microsoft.com/security/security_bulletins/ms03-026.asp and/or to
visit Windows Update at
http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026.”