
Note: The workbook which contains the macro must be open. If you need to open the workbook first, check out the code in this post. To use parameters using this method the syntax is as follows: Sub CallAnotherMacro()ĭim MacroName As String Dim argument1 As String Dim argument2 As IntegerĮnd Sub Run a macro contained in another workbook In the code above, the Run command is not followed by a text string, but by a variable. The Run function works because the variable is a text string.

It is easy to read because it is clear that another macro is being run.

Using the Call statement is my preferred method. Sub CallAnotherMacro()ĭim argument1 As String Dim argument2 As Integer When using this method with parameters/arguments, the first argument follows the name of the macro, each subsequent argument is separated by a comma. In this code example, only the macro’s name is required. There are 3 common methods for calling a macro contained in the same workbook.

Run a macro from a macro in the same workbook

Calling and running macros from Workbook, Worksheet or UserForm Modules.Run a macro contained in another workbook based on a variable.Run a macro contained in another workbook.Run a macro from a macro in the same workbook.
