Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
mel mel is offline
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call Center Management: How to calculate 'cost per call' Denniso6 Excel Discussion (Misc queries) 2 June 25th 06 05:01 PM
generate a random number and use if function to generate new data Dogdoc1142 Excel Worksheet Functions 4 April 26th 06 03:44 AM
How do I programmatically specify a range. Hari[_3_] Excel Programming 4 January 17th 05 03:31 PM
delete row programmatically Pat Excel Programming 2 September 2nd 04 09:11 PM
Programmatically Add Reference` Jean-Paul Viel Excel Programming 0 September 16th 03 02:23 PM


All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"