none
Run a subroutine via a variable RRS feed

  • Question

  • I want to be able to run a Sub by variable, sorta like this:

    Sub zXMacro()
    ' Alt M:  Temporary macro key; use Alt-Shift-M to define
    If xMacro <> "" Then Call xMacro
    End Sub

    xMacro is declared as a string in "Declarations."  The above code gives an error message, and apparently Run is not a keyword.

    Thanks for your attention.

    Alan

    Wednesday, August 15, 2018 7:02 PM

Answers

All replies

  • You can use Application.Run:

    Sub zXMacro()
         ' Alt M: Temporary macro key; use Alt-Shift-M to define
         If xMacro <> "" Then Application.Run xMacro
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, August 15, 2018 9:52 PM
  • Did the trick.  Thanks very much!

    Alan

    Thursday, August 16, 2018 1:11 AM