Recording a Macro - Exercise

Contact Us or call 1-877-932-8228
Recording a Macro - Exercise

Recording a Macro

Duration: 10 to 20 minutes.

In this exercise, you will record a macro that adds a custom header and footer to a Microsoft Excel workbook.

  1. Open Macros.xlsx from your Excel2013.3/Exercises folder.
  2. Record a macro named "CustomHF" to add a custom header and footer to your workbook. Specifically, the macro should:
    1. Add the word "CONFIDENTIAL" in the center of the header.
    2. Add the date on the right side of the header.
    3. Add the page number to the center of the footer.

Solution:

  1. On the VIEW tab, in the Macros group, click the Macros command:Macros Command
  2. Click Record Macro:Record Macro Command
  3. In the Record Macro dialog box:
    1. Enter the Macro name of "CustomHF".
    2. Enter a Shortcut key.
    3. Accept the default to store the macro in this workbook.
    4. Enter a Description such as "Custom header and footer."
    5. Click OK.Record Macro Dialog Box
  4. After clicking OK, every keystroke is recorded. Following are specific instructions:
    1. Click FILE, then Print, and then Page Setup:Page Setup
    2. Select the Header/Footer tab and then click Custom Header:Custom Header
    3. Tab to or click in the Center section and type "CONFIDENTIAL". Then tab to or click in the Right section, click the Insert Date icon, and then click OK:Insert Date
    4. Click Custom Footer:Custom Footer
    5. Tab to or click in the Center section, click the Insert Page Number icon, and then click OK:Page Number
    6. You are now back in the Page Setup dialog box. Click OK:Page Setup Dialog Box
    7. On the VIEW tab, in the Macros group, click the Macros command and then click Stop Recording:Stop Recording Command
Next