ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Storing a Macro name in a Variable (https://www.excelbanter.com/excel-programming/312525-storing-macro-name-variable.html)

Jack Adams

Storing a Macro name in a Variable
 
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

Geof

Storing a Macro name in a Variable
 
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.
-----Original Message-----
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
.


Tom Ogilvy

Storing a Macro name in a Variable
 
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

--
Regards,
Tom Ogilvy


"Jack Adams" wrote in message
...
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





All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com