Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programmatically generate name of functition to call
I want to use a string variable to formulate the name of
the function to call, I can create the name in a string variable, but how do you use the variable to call the function. e.g. Str1=MyFunction1 I tried str1(arg1) and it didnt work. If I use Myfunction1(arg1) then it works . I know there must be a special way to call functions if the name is in a variable. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programmatically generate name of functition to call
I believe you are looking for the "Run" command. Here's a small demo.
Function MyFunction(x) MyFunction = 2 * x End Function Sub Main() Dim n Dim s s = "MyFunction" n = 3 Debug.Print Run(s, n) End Sub HTH. :) -- Dana DeLouis Win XP & Office 2003 "Mel" wrote in message ... I want to use a string variable to formulate the name of the function to call, I can create the name in a string variable, but how do you use the variable to call the function. e.g. Str1=MyFunction1 I tried str1(arg1) and it didnt work. If I use Myfunction1(arg1) then it works . I know there must be a special way to call functions if the name is in a variable. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Call Center Management: How to calculate 'cost per call' | Excel Discussion (Misc queries) | |||
generate a random number and use if function to generate new data | Excel Worksheet Functions | |||
How do I programmatically specify a range. | Excel Programming | |||
delete row programmatically | Excel Programming | |||
Programmatically Add Reference` | Excel Programming |