View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default how to call a function with variance which is function Name

Use Run (to call a SUB, which is not a function)

Run can be used to call a function as well as a sub.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jean-Yves" wrote in message
...
Hi,


Use Run (to call a SUB, which is not a function)
A function return a value, not a sub


Sub test()
MsgBox "tesst"
End Sub

Sub testcall()
Dim str As String
str = "test"
Run str
End Sub

Regards,
Jean-Yves

"miao jie" wrote in message
...
Hi,
now I have a case to wanna use a string variance stand for

function
name
to call a function, but I'm fail to do it. my test program as

follow,
Sub test_call_function()
Dim functionName As String

functionName = "test_split_string"

' Call functionName("dss")
functionName "dss"
End Sub

Sub test_split_string(ByVal test As String)
Dim fieldArry
Dim i As Integer

fieldArry = Split("24354.54,34546.5,3324.67", ",")
For i = 0 To UBound(fieldArry, 1)
MsgBox fieldArry(i)
Next
MsgBox test
End Sub

the VBA tell me a compile error for
functionName "dss"

anyone can show me a way to use variance as function name to

call it.
thanks
in advance.