Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. 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 November 17, 2018)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


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.

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, and Excel in Microsoft 365. 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

Continuing Your Numbering

If you have a couple of numbered lists separated by regular text paragraphs, you might want the secondary lists to be ...

Discover More

Inconsistent Adding of Words to a Custom Dictionary

Custom dictionaries are a great way to adapt the spelling and grammar checkers to your needs. If you find that Word isn't ...

Discover More

Pulling Initial Letters from a String

When working with names or a different series of words, you may need to pull the initial letters from each word in the ...

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)

Pulling Apart Characters in a Long String

You can easily use formulas to pull apart text stored in a cell. For instance, if you need to pull individual characters ...

Discover More

Deriving an Absolute Value in a Macro

Need to figure out an absolute value within your macro code? It's easy to do using the Abs function, described in this tip.

Discover More

Finding the Last-Used Cell in a Macro

Ever wonder what the macro-oriented equivalent of pressing Ctrl+End is? Here's the code and some caveats on using it.

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 three more than 9?

2019-03-29 17:23:53

Dennis Costello

I haven't used the Record a Macro feature recently, but found it was a great way to begin to learn the basics of VBA (pun intended). One thing that annoyed me is that it always seemed to generate VBA code that looked more or less like this:

<range>.SELECT
SELECTION.<action>

I would almost always shorten these sequences to <range>.<action>

For instance, instead of
Range("F54").Select
Selection.Font.Bold = True
generated by the Macro Recorder, I would use
Range("F54").Font.Bold = True

This is, in my opinion, not only easier to read and understand, but possibly also executes faster - because Selection could be a simple range of a single cell, or a "3-dimensional" selection across multiple tabs and including multiple areas on each, and so VBA interpreter has to wade through code that can handle all the possible cases. Writing it my way, the interpreter can see right away that the action is being taken on a simple range.

I don't know if this is significant for VBA, but in other interpreted languages I've worked with in the past that include a similar Select concept, it did matter.

Having said that, the way the Recorder shows it might be the more "honest" approach - recording clicking on a cell as a Select, separate from the action taken on the cell(s) so selected.


2018-11-23 05:47:27

Peter Atherton

Raymond

Seems like you use a Mac. On windows there is a short-cut to save the document Ctrl + S, Ctrl + P to print and so on. If you use these shortcuts in your workbook then you will not be able to use them to save or print a file. The usual worokaround is to add the Shift to yhe short cut. e.g Ctrl + shift + S. Try these short cuts to make sure that Excel is nt usng them before they are apied to your workbook.

HTH


2018-11-22 13:02:26

Raymond A Batman

When I use the ctrl+ command I get an insert box that provides ways to shift cells. So that does not allow me to use a shortcut key to record a macro?


2018-11-19 05:50:16

Barry

@JeanE

The macro recorder default to using absolute addresses, which is a nuisance as the majority of times, that I've used the recorder, I want relative addresses. Fortunately, this is easily enabled by slicking the "Use Relative References" in the ribbon on the 'Developer' tab or on older versions of Excel the Use RElative Reference button on the floating "Macro" recorder toolbar.
You can switch between absolute and relative as frequently as you like during the recording of the macro. E.g. I had a macro to go to the last entry in column A - in absolute mode go to the last cell in column A then switch relative to then use the [End} [UpArrow] to go to the last cell.


2018-11-18 11:40:31

JeanE

The steps mentioned to create a macro work great, but only on the cell the macro was recorded in. How do I make the macro run in any other cell in the workbook -- in other words, address free?


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.