Two Steps to Excel 2010 Macro (Recording and Running)

 

Step 1: Record Excel 2010 Macro

When the “Record Macro” window appears, type a name for the macro in the Macro Name field. Be sure to type continuous characters. For example, type Macro1 without a space, not Macro 1 with a space. You should use a meaningful name for the macro. A name such as FormatReport is more useful than Macro1. The second field in the Record Macro dialog box is a shortcut key. If you type J in this field, and then press Ctrl+J, this macro runs. Note that most of the lowercase shortcuts from Ctrl+a through Ctrl+z already have a use in Excel. Don’t limit yourself to the unassigned Ctrl+j; You can hold down the Shift key and type Shift+A through Shift+Z in the shortcut box, which will assign the macro to Ctrl+Shift+A. In the Record Macro dialog box, choose where you want to save a macro when it is recorded: Personal Macro Workbook, New Workbook, This Workbook.


It is recommended that you store macros related to a particular workbook in This Workbook. The Personal Macro Workbook (file.xlsm) is not a visible workbook; it is created if you choose to save the recording in the Personal Macro Workbook. This workbook is used to save a macro in a workbook that will open automatically when you start Excel, which enables you to use the macro. After Excel is started, the workbook is hidden. If you want to display it, select Unhide from the View tab. The fourth box in the Record Macro dialog is for a description. This description is added as a comment to the beginning of your macro.

Legacy versions of Excel automatically note the date and username of the person recording the macro. Excel 2010 no longer automatically inserts this information in the Description field. After selecting the location of where you want to store the macro, click OK. Record your macro. When you are done recording the macro, click the Stop Recording icon in the Developer tab.

 

Step 2: Running Excel 2010 Macro

If you assigned a shortcut key to your macro, play it by pressing the key combination. Macros also can be assigned to toolbar buttons, forms controls, drawing objects, or run them from the Visual Basic toolbar.

You can add an icon to a new group on the Ribbon to run your macro, more appropriate for macros stored in the Personal Macro Workbook.