How to Merge Two Macros in Excel

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.

Macros consist of Visual Basic programming code. They are convenient to use in Microsoft Excel to automate many common tasks a user would generally conduct manually. Macros save users vast amounts of time. For example, if a user has to click through a list of links and copy and paste the data into the worksheet, a macro can be written to loop through the links, rather than performing the same tasks for each link. Multiple macros can be combined into a single macro, so the user only has to run this master macro instead of all the individual macros.


Step 1

Create a master macro by clicking on the "View" tab in the toolbar. Click on "Macros" and select "View Macros." Type the name of the master macro, such as "Master," in the "Macro name" box. Click on the "Create" button to launch the Visual Basic editor.


Video of the Day

Step 2

Place the cursor in the second line under the subroutine. For example, if the name of the macro you created is "Master," the first line is "Sub Master()." Under this line, type "Call," followed by the name of the first macro you would like to run. For example, if you created a macro called "GetWebQueries" that loops through a list of URLs, opening each one and copying and pasting the data from a table into a new worksheet, you would type "Call GetWebQueries()."


Step 3

Press "Enter" to go to the next line. Type "Call," followed by the name of the second macro, such as "Call Format()," which would run the Format macro that formats each worksheet in a specified manner. Save the macro and close the Visual Basic editor.


Step 4

Run the master macro by clicking on the "View" tab. Click on "Macros" and select "View Macros." Select the master macro and click on the "Run" button. The master macro will run "GetWebQueries" and the "Format" macros in the specified order.



Report an Issue

screenshot of the current page

Screenshot loading...