Run macro action
- Updated: 2024/11/05
Run macro action
The Run macro action in the Excel advanced package enables you to run macros in a worksheet.
Settings
- Double-click or drag the Run macro action in the Actions palette.
- In the Macro name field, enter the name of the macro that you
want to run.
(Optional) Click the Insert a value icon to select an existing variable that you have used to store the name of the macro.
- (Optional) In the Macro arguments field, enter the argument
details or click the Insert a value icon to select an existing
variable that you have used to store macro arguments.
Few examples of argument details are Arg1, Arg2, Arg3 and so on. When you use the Run macro action and specify an argument that has a blank value, this blank value can now be passed to the macro.
- Use the Session name field to select one of the following
options:
- Session name: Enter
the name of the session used to open the workbook
with the Open
action.
(Optional) Click the Insert a value icon to select an existing variable that you have used to store the default session name.
- Variable: Enter the name of the variable that you have used to store the session name.
- Session name: Enter
the name of the session used to open the workbook
with the Open
action.
Note:
- When you write a macro code, use
Exit Sub
to exit or end a specific procedure at any point. - Ensure that a macro code contains only
one instance of the
End
orEnd Sub
statement to terminate the macro. If there is more than one instance of the statement, then on execution, the bot might fail with an error.
Consider the following example where you want to get an input box and exit the
procedure if a user's reply is not a number:
Sub vba_exit_sub_example()
If IsNumeric(InputBox("Enter your age.", "Age")) = False Then
MsgBox "Error! Enter a numeric value only."
Exit Sub
Else
MsgBox "Thank you."
End If
End Sub