Browse » Home
Thursday, February 23, 2012
How to Code a VBA Excel 2007 Macro Consolidation
1. Go to the 'View' tab in the Microsoft Excel toolbar. Click on the 'Macros' button and select 'View Macros' Enter a new macro name for the master macro such as 'All' and click on the 'Create' button to launch the Visual Basic editor.
2. Go to the second line in between the macro name and end of the macro. In our example, it would appear as 'Sub All()' and 'End Sub'. Type 'Call' followed by each of the individual macro names you would like to run in preferential order. For example, we could have a macro named 'Links' that goes through a range of links and copies and pastes data from linked excel spreadsheets into a master sheet. Another macro called 'Format' sorts the data and adjusts the font type and size.Sub All()Call LinksCall FormatEnd Sub
3. Save the code and go back to the Excel template. Click on the 'View' tab and go to the 'Macros' button. Select the name of the master macro and click on 'Run.' This will run the individual macros that were created in order. In our example, it will run 'Links' first. Once it's completed, it will automatically run 'Format' next.