MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Activating macro from cell text


Posted by Peter C on February 22, 2001 1:40 PM

A number of my macros use a large amount of If statements, particularly for month related functions, ie, Update_Jan, Update_Feb, etc. Can a macro be run from reading text in a cell,eg Update_Oct and it runs the "Update_Oct" macro without having to use twelve different If statements in VB?

I Hope this makes sense, thanks.


Posted by David Hawley on February 22, 2001 8:39 PM

Hi peter

It sure can:

Sub TryThis()
Dim MyMacro As String
[A1] = "Hello"
MyMacro = [A1]
Run MyMacro
End Sub

Sub Hello()
MsgBox "Hello"
End Sub


Dave

OzGrid Business Applications