Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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

by Allen Wyatt
(last updated July 24, 2017)

5

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5683) applies to Microsoft Excel 2007, 2010, and 2013. 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

Defining Styles

Styles are a powerful component of Word. You use them to determine the way that your text should appear. This tip explains ...

Discover More

Filling References to Another Workbook

When you create references to cells in other workbooks, Excel, by default, makes the references absolute. This makes it ...

Discover More

Adding a Report

The Report Manager allows you to create specialized reports that can be easily printed from your worksheet data. This tip ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Stopping a Checked Box from being Unchecked

When creating user forms for use in Excel, you are provided with a range of controls you can add, including check boxes. If ...

Discover More

Using InputBox to Get Data

Need your macro to get some input from a user? The standard way to do this is with the InputBox function, described in this ...

Discover More

Testing if a Workbook is Open

Your macros can easily open and manipulate other Excel workbooks. If a workbook you are trying to use is already in use by ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 7 - 0?

2017-07-26 02:21:32

Barry

@MalR
If you Google "record macro using relative cell references excel" you'll get several useful links and YouTube videos.


2017-07-25 22:35:36

MalR

@ Barry
Barry regarding the offsets you mentioned. I have a macro that puts a calendar into a word template. If I make even a minor change to the template it drops the calendar way off from where it should. I can fiddle with the offsets to get it to where it should be but it is often quicker to rebuild the macro and start again. Is there any link that explains how these offsets work? I could not find anything that is helpful.


2017-07-24 04:53:26

Barry

@Mike
You've stumbled upon an issue with the macro recorder in that it hasn't kept pace with additions to Excels' functionality (although generally, VBA has).
It seems that Microsoft has forgotten to keep this updated with new features that it has added in recent releases of Excel.
Unfortunately, there isn't a way around this, and you'll just have to delve in the bowels of Excel VBA I'm afraid, and/or scour the internet forums for snippets of code/assistance. I suggest starting with the Excel VBA Object model, Google "excel vba chart object model" will give some useful links.


2017-07-24 04:38:47

Barry

When recording a macro the default Excel uses is to use absolute addressing. That if you move to Cell C5 the macro record just that. However, on the Developer Tab you can change the setting to "Use Relative References" which in the example above if the cell originally selected was A1 the macro would record the offset from cell A1 to cell C5. This means when the macro is re-run and the cell selected was B2, then cell D6 will be selected.

By judicious switching between absolute referencing and relative referencing you can get a better macro based result. I would recommend starting any macro with absolute (as you will never know where the selected cell is, then switch to relative and back as appropriate thereafter.


2015-07-08 08:06:48

Mike

Hi Allen,

Naive question. I do this all time, but in 2007 all I get are Activiate lines like:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlCategory).Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate

(the above formatted major gridlines and the minor Catergory gridline).

Is there a setting that will allow the parameters to be visible?

Thanks

Mike Virostko


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.