Storing a Macro name in a Variable

  • Thread starter Thread starter Jack Adams
  • Start date Start date
J

Jack Adams

Is there a way to store the name of a macro (with or
without parameters) in a named variable and then activate
the macro using the variable reference name?

Thanks,

Jack

This doesn't work but is waht I am trying to accomplish

Dim xMacro
xMarco = "ApplicationName"

Application. run ApplicationName

Likewise for a macro with parameters
 
Jack,
If it's a VBA procedure, try Call xyz(). If it has
parameters try Call xyz(prm1, prm2). Or do you really want
to run Excel 4 mactos?
Geof.
 
Dim xMacro
xMacro = "ApplicationName"

Application.run xMacro


Sub Macro1(x, y)
MsgBox x & " " & y
End Sub

Sub Macro2()
Dim xMacro
xMacro = "Macro1"
Application.Run xMacro, "StringArg1", 29
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top