Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Recording a Macro.

Recording a Macro

Written by Allen Wyatt (last updated January 27, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

If you have a repetitive task that is a good candidate for a macro, you can use the macro recording capabilities of Excel to turn your actions into a macro. To record a macro, follow these steps:

  1. Display the Developer tab of the ribbon.
  2. Click the Record Macro tool. Excel displays the Record Macro dialog box. (See Figure 1.)
  3. Figure 1. The Record Macro dialog box.

  4. In the Macro Name field, provide a name you want used for your macro. You can accept the default name, if you desire, but if you plan on using the macro more than once or twice, you will want to use a more descriptive name. The name you provide must not include any spaces.
  5. In the Description box you can provide an optional comment about your macro.
  6. Use the Store Macro In drop-down list to specify where you want the macro stored.
  7. Click OK.

Excel starts recording everything you do. The actions you take become steps in the macro and will be repeated when you later execute the macro. When you have finished the steps you want recorded in your macro, again display the Developer tab of the ribbon and click the Stop Recording tool. (This tool is only available when you are actually recording your macro.) The macro is then saved and available for use at any time.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5683) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Recording a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Printing Only Selected Rows from a Table

Tables are a great way to organize the information in a document. If your table gets quite long, you may not want to ...

Discover More

Searching Through Many Workbooks

If you have a folder that contains dozens or hundreds of workbooks, you may need to search through those workbooks to ...

Discover More

Creating Page Footers and Headers

Headers and footers can add a final, professional touch to your printed document. Here's the quick way to add the headers ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Pausing Macros for User Input

Does your macro need to get some input from a user? Here are the ways that Excel provides for that input to be solicited.

Discover More

Displaying the First Worksheet in a Macro

When creating macros, you often have to know how to display individual worksheets. VBA provides several ways you can ...

Discover More

Storing a User's Location before Running a Macro

Macros are often used to process information in a workbook. If your macro makes changes in what is selected in the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2024-01-29 12:16:39

J. Woolley

BARRY mentioned the "Use relative references" function (option) but was vague about how. It is in the Code group of the Ribbon's Developer tab under the Record Macro "tool" discussed in the Tip.
See https://www.excel-easy.com/vba/examples/use-relative-references.html

You might also notice the Record Macro "tool" near the left side of the Status Bar at the bottom of Excel's window. If you don't see it, right-click the Status Bar and press M to enable it (Macro Recording). This makes it easy to start and stop recording, but you still must use the Ribbon's Developer tab to toggle the status of Use Relative References (which is always FALSE when Excel starts).

The status of Use Relative References can be reviewed (but not set) in VBA using the Application.RecordRelative property. My Excel Toolbox includes the following function:
    =VBAResult(Expression)
where the text argument is a VBA expression (right side of equal sign). So this cell formula will return the current status of Use Relative References:
    =VBAResult("Application.RecordRelative")
See https://sites.google.com/view/MyExcelToolbox/


2024-01-27 07:11:17

BARRY

The macro recorder is a useful tool for those not into VBA. However it's default setting of using absolute addresses can be quite limiting, flipping judicially between that and relative addressing whilst recording the macro greatly improves the usefulness of any macro that you may record.
The "Use relative references" function does this, accessing it depends upon your version of Excel.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.