Call a VBA function by string value

2

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'

David Gard

Posted 2012-10-18T10:48:30.307

Reputation: 1 368

Answers

3

Try using Application.Run to call it.

Application.Run function_name

CharlieRB

Posted 2012-10-18T10:48:30.307

Reputation: 21 303

1Run, that's the bad boy. Thanks for the help. – David Gard – 2012-10-18T15:21:19.430

0

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

Joshua Coppersmith

Posted 2012-10-18T10:48:30.307

Reputation: 1

2http://superuser.com/help/how-to-answer – Kevin Panko – 2014-02-24T23:39:49.613