To record a macro in Microsoft Excel:
- On the VIEW tab, in the Macros group, click the Macros command:
- Click Record Macro:
- In the Record Macro dialog box:
- Enter a Macro name. Choose a name that clearly identifies the macro. You cannot use spaces.
- Enter a Shortcut key. You will be able to run the macro using this shortcut key.
- Choose where to store the macro. You will normally accept the default (This Workbook).
- Enter a Description. Briefly explain what the macro does.
- Click OK.
- After clicking OK, every keystroke is recorded.
- To stop recording, on the VIEW tab, in the Macros group, click the Macros command and then click Stop Recording:
Copy a Macro from Workbook to Workbook
You can copy macros to different workbooks. First you need to ensure the DEVELOPER tab is active on the Ribbon. To add it:
- Right-click the Ribbon and select Customize the Ribbon.
- Select Customize Ribbon, and on the right, select the Developer check box and click OK.
Now you need to enable and copy the macros:
- Select the DEVELOPER tab, and select Macro Security from the Code group.
- Under Macro Settings, select Enable all macros and click OK.
- Open both the source and destination workbook.
- Select the DEVELOPER tab, and select Visual Basic from the Code group.
- From the Project Explorer pane, press Ctrl and drag the module from the source to the destination workbook.
- Close the Visual Basic window and save the workbook.