Macros
Macros
Definition: An Excel macro is a set of instructions that can be triggered by a keyboard shortcut, toolbar button or an icon in a spreadsheet. Macros are used to eliminate the need to repeat the steps of common tasks over and over. Tasks such as: adding or removing rows and columns protecting or unprotecting worksheets selecting a range of cells adding the current date to a spreadsheet
In Excel, macros are written in Visual Basic for Applications (VBA). For those who cannot write VBA code, Excel allows you to record a series of steps - using keyboard and mouse - that Excel then converts into VBA. Excel Macro Recorder
The easiest way to create a macro in Excel is to use the macro recorder. To do so, click Tools > Macros > Record New Macro from the menus to bring up the Record Macro dialog box. The Macro Recorder dialogue box
There are 4 options to complete in this dialog box: 1. Name give your macro a descriptive name. 2. Shortcut key - (optional) fill in a letter in the available space. This will allow you to run the macro by holding down the CTRL key and pressing the chosen letter on the keyboard. 3. Store macro in Options: o the current workbook o The macro is available only in this file.
a new workbook This option opens a new Excel file. The macro is available only in this new file.
a personal macro workbook. This option creates a hidden file Personal.xls which stores your macros and makes them available to you in all Excel files.
When finished setting your options in the Macro Recorder dialogue box in the previous step of this tutorial, click the OK button to start the macro recorder. The Stop Recording toolbar should also appear on screen. The macro recorder records all keystrokes and clicks of the mouse. Create your macro by: manually going though all the necessary steps.
When finished, click the stop button (small blue square) on the Stop Recording toolbar.
If the Stop Recording toolbar is not available, click Tools > Macros > Stop Recording from the menus to stop recording.
To run a macro you have recorded: If you chose a shortcut key when creating the macro, hold down the CTRL key on the keyboard and press the shortcut key. Otherwise, 1. Click Tools > Macros > Macro from the menus to bring up the Macro dialogue box. 2. Select a macro from the list of those available. 3. Click the Run button.