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 |
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 |
All times are GMT +1. The time now is 06:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com