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

by Allen Wyatt
(last updated November 17, 2018)

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 Office 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

Referencing the Last Cell in a Column

When developing formulas, you may need to reference the very last value in a particular column. This can seem perplexing, ...

Discover More

Conditional Format that Checks for Data Type

Conditional formatting can be used to highlight cells that contain the improper type of data for your needs. This tip ...

Discover More

Turning Off Smart Quotes for Specific Styles

Smart quotes can be helpful in making a great-looking document, but at times, they can be a real pain. Wouldn’t it be ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Reversing Names In Place

Do you want a way to reverse names within a cell, making them "last, first" instead of "first last?" Here's a handy macro ...

Discover More

Selectively Importing Records

Want to easily control which records get imported from a text file into Excel? It's easy to do when you write the macro ...

Discover More

Out of Memory Errors when Accessing the VBA Editor

It can be frustrating when you get error messages doing something that you previously did with no errors. If you get an ...

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 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 3?

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.