Excel 2016 Macros

Lesson 2 - Recording Macros

Excel 2016

R ECORDING A M ACRO  D ISCUSSION

A macro executes a series of previously recorded and saved actions. You can create macros for repetitious tasks you perform frequently or to automate tasks that involve a lengthy number of steps. When using macros, you can be assured that the task is performed in exactly same way each time; therefore, macros can ensure consistency and accuracy, as well as save you time.

Before you create a macro, it is a good idea to make sure that you know all the steps needed to perform the desired procedure so that you can record the macro properly. The steps you carry out are not recorded as simple keystrokes; they are translated into the Visual Basic for Application programming language, which translates your steps into macro statements. When you record a macro, Excel creates a module containing the Visual Basic language statements used to define and create the macro. A module can contain more than one macro. You use the macro recorder to record a macro which captures each keystroke and menu selection, with some exceptions. For example, navigation on the Ribbon is not included in the recorded steps. If you make a typing error and press the [Backspace] key to correct it, neither the error nor the [Backspace] command is recorded. Likewise, if you select the Cancel button to close a dialog box, neither the command that opened the dialog box nor the Cancel command is recorded.

While the macro recorder is running, the Record Macro button in the Code group on the Developer tab changes into the Stop Recording button. A Stop Recording button also appears on the left-hand side of the status bar.

During the macro recording process, you name the macro and enter descriptive information into the Record Macro dialog box. This information appears as a comment in the module.

You should assign a name to the macro that identifies what the macro will accomplish. Although a macro name must begin with a letter, it can contain both letters and numbers. A macro name cannot contain any spaces or symbols, but you can use an underscore ( _ ) character to separate words. If you use a macro name that is also a cell reference, an error message may appear to inform you that the macro name is invalid. In addition to naming the macro, you can select where you want to store it. Macros can be stored in the current workbook, a new workbook or the Personal Macro Workbook . Macros stored in a current or new workbook are only available when that workbook is open. If you want a macro to be available whenever you use Excel, you can store it in the Personal Macro Workbook . This is saved in the XLStart folder and will open automatically whenever Excel starts.

Page 28

OFFICEPRO, Inc.

Made with FlippingBook - professional solution for displaying marketing and sales documents online