Please download IntroExcel-Part2-SampleWorkbook.xlsx to follow along with workshop activities.

Throughout this workshop Click refers to a Left Click with your mouse

Record and Test Macros

If you frequently use Excel to work with similar worksheets and find yourself doing the same tasks again and again, macros can help you automate those tasks.

Macros allow you to record specific actions and complete those actions in other workbooks.

This lesson will show you how to all the steps needed to create a macro:

  1. Enable the developer tab
  2. Record a macro
  3. Test a macro
  4. View the Personal Macro Workbook
  5. Delete a macro

It will also share a few helpful hints about macros, offer resources for more help, detail the difference between relative and absolute references, and help you find your Personal Macro Workbook file location.

Create a macro

The macro tool is located under the Developer tab in Excel, which is hidden by default.

Enable the developer tab

To enable the Developer tab on a PC:

To enable the Developer tab on a Mac:

We can now see the Developer tab at the top of our Excel workbook.

Record a macro

Let’s navigate to Sheet 3 in our workbook.

Sheet 3 is an example of a worksheet with consistent organization (i.e. number of columns, column headings, etc.).

Although the actual data changes each month (titles, authors, etc. are different), the organization stays exactly the same. Every time I download a new version of the worksheet, I complete the same formatting and organization tasks to make the sheet more readable.

Since this Excel worksheet stays consistent, we can record macros that allow us to automate certain tasks when we download future versions of this worksheet.

We will focus on recording a macro for two types of tasks:

  1. Format a column
  2. Apply the PROPER function to a specific column

Format a column

Now we can record the BookListFormatISBNColumnMacro action:

Apply the PROPER function to a specific column

This macro will include four parts:

Part 1: Insert a new column

Now we can record the BookListInsertColumnMacro action:

Part 2: Insert the PROPER function

Now we can record the BookListProperFunctionMacro action:

Part 3: Copy and paste values

Now we can record the BookListCopyPasteValuesMacro action:

Part 4: Delete a column

Now we can record the BookListDeleteDuplicateTitleColumnMacro action:

Test a macro

Now that we have recorded these macros, let’s test them on a new version of the same data.

First, let’s download IntroExcel-Part2-SampleTestaMacroWorkbook.xlsx, open it on your computer, and click enable editing if prompted.

We can then use the same steps to test the other macros:

View the Personal Macro Workbook

Since we stored all the macros in the Personal Macro Workbook, we can run these in any Excel workbook. When you open Excel, the Personal Macro Workbook is hidden by default and you must unhide this workbook to delete a macro.

To view the Personal Macro Workbook

To hide the Personal Macro Workbook

When you record macros or hide/unhide the Personal Macro Workbook, you must save your changes to PERSONAL.XLSB when prompted. You will see the following prompt when you attempt to close Excel after making changes to the Personal Macro Workbook:

Microsoft Excel Personal Macro Workbook Save Prompt

To save your changes, click Save.

Delete a macro

After following the instructions above to view the Personal Macro Workbook:

When you delete a macro, you must save your changes to PERSONAL.XLSB when prompted.

Helpful hints about macros

More Help

To learn more about macros, visit Microsoft’s Macro website.

Difference between relative and absolute references

This lesson has focused on using relative references when recording macros as it gives you more flexibility.

In contrast, recording a macro with absolute references allows you to only run the macro on a specific cell or cell range, column, or row.

Find your Personal Macro Workbook file location