How to Chain or Repeat Multiple VBA Macros in Excel
Question details
The user needs to execute several VBA macros in a specific sequence or run a single macro a specified number of times.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Automating complex spreadsheet workflows that require triggering multiple pre-existing macros in order, or looping a process automatically.
- Observed behavior
- The user is looking to create a master script to call other macro procedures sequentially or loop them iteratively.
Ensure you have your individual macros written and tested independently. Save your workbook as a Macro-Enabled Workbook (.xlsm) to ensure your VBA scripts are preserved.
Run Multiple Macros Sequentially Using the Call Statement
Create a master macro that acts as a controller to trigger other macros in a specific order using the VBA 'Call' command.
The easiest way to chain macros is to create a new subroutine that contains a sequence of 'Call' statements. When this master macro is run, it executes each specified macro one by one.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In an existing module or a newly inserted module (Insert > Module), type 'Sub MasterMacro()' and press Enter.
Inside the subroutine, type 'Call' followed by the name of the first macro you want to run (e.g., 'Call Macro1'). On the next line, type 'Call Macro2', and continue for all required macros.
Close the VBA editor, press Alt + F8 to open the Macro dialog box, select 'MasterMacro', and click 'Run'.

Repeat a Macro Using a For Loop
Use a VBA 'For...Next' loop to execute the same macro a specific number of times automatically.
Automate Tasks Seamlessly with WPS Spreadsheet
WPS Spreadsheet offers robust support for VBA and macros, allowing you to write, edit, chain, and execute scripts easily to streamline complex automation workflows.
- 1. Open Your Workbook: Launch WPS Office and open your .xlsm file containing the individual macros.
- 2. Access the VBA Editor: Go to the 'Developer' tab on the ribbon and click 'VBA Editor' to open the scripting environment.
- 3. Write the Master Script: Use standard VBA syntax, such as the 'Call' method or 'For...Next' loops, to build your sequence or repetition logic.
- 4. Execute the Workflow: Click 'Macros' in the Developer tab, choose your new master script, and click 'Run'.

Frequently Asked Questions
Do I absolutely need to use the 'Call' keyword to run another macro?
While not strictly required (you can simply type the macro's name on a line by itself), using the 'Call' keyword is highly recommended. It makes your code more readable and explicitly shows that another subroutine is being executed.
Can I pass variables or arguments between chained macros?
Yes. If your receiving macro is designed to accept parameters (e.g., Sub Macro2(myVar As String)), you can pass variables from your master macro using the Call statement like this: Call Macro2(myVariable).
What happens if an error occurs in one of the chained macros?
By default, an error in any of the chained macros will halt the entire process and display a standard VBA error dialog. You can implement 'On Error GoTo' error-handling blocks in your master macro to manage these interruptions gracefully.
Why won't my master macro show up when I press Alt + F8?
If your macro is defined as a 'Private Sub' or requires parameters, it will not appear in the standard Macro dialog box. Ensure it is defined simply as 'Sub MasterMacro()' with no parameters inside the parentheses.




