Recording Macros

A VB Macro is essentially a VB subroutine that executes a series of VB statements.  To generate a macro, click on the Record Macro button in the VB Toolbar.  You will then be prompted for the name of the macro.  Then you select a series of menu commands and/or make changes to your spreadsheet.  When finished, you select the Stop Recording button .  To view the code associated with the macro, go to the Project window, expand the Modules folder and double click on the Module1 item.

Macros are extremely useful when you are first learning how to write VBA code in Excel.  If you want to do something in code such as change the background color of a cell, but you don't know to do it, simply run a macro, change the color manually, and then look at the macro.  You can learn how to do just about anything simply by running macros.