In VBA, is there a way to call a function by string value?

For example -

Dim function_name, value1, value2 as String

value1 = "test"
value2 = "Function"
function_name = value1 & value2 ' So function name = 'testFunction'

call function_name ' But this calls a function called 'function_name', where as I require a funtion called 'testFunction'

Try using Application.Run to call it.

Application.Run function_name

  • 1
    Run, that's the bad boy. Thanks for the help. – David Gard Oct 18 '12 at 15:21

Or check out CallByName from VBA itself. VB looks a little dated but it is the promise of COM realized.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.