Wednesday, November 20, 2013

How to Merge Two Macros in Excel


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.
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().'
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.
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.

Blogger news