Written by Allen Wyatt (last updated July 21, 2018)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
One of the most common ways of creating a macro is to use the macro recorder built into Excel. The recorder allows you to record your keystrokes and play them back again later. When you record your macros, Excel is very literal about recording what you do. For instance, if you start recording while cell B7 is selected, and then you press the Down Arrow key, cell B8 is now selected.
When you later select cell E12 and play back this macro, you might expect that the macro would move down one cell, to E13, as if you had pressed the Down Arrow key. Instead, when that line of the macro is executed, cell B8 is selected.
The reason this happens is that Excel memorized your absolute steps. It didn't record the press of the Down Arrow key, but instead recorded the movement to cell B8. This exemplifies the default condition of the macro recorder—to record all movements and cell references absolutely.
If you instead want your macros to be recorded relatively (so that the macro moves down one cell instead of moving to cell B8), then you need to instruct Excel to do so. You do this by clicking Use Relative References on the Developer tab of the ribbon. After clicking, all your subsequent actions are interpreted relative to the currently selected cell. Click the tool a second time, and you are back to subsequent actions being interpreted absolutely.
It is important that you remember to click the appropriate tool before you take an action that is recorded. The tool's state (on or off) affects only the recording of future actions, not what has been already recorded.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3331) 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: Relative References when Recording Macros.
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!
If you have a series of values in a column, you might have a need to separate the values into even values and odd values. ...
Discover MoreNeed to put together a bunch of characters to create a text string? You can do it in your macros by using the String ...
Discover MoreNamed ranges are a great tool to use in developing formula-heavy workbooks. You may want, at some point, to copy your ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-08-01 23:07:50
rafael robyns
There is no such way to do this on Mac.
2018-07-21 13:50:03
Chester Hood
This will be very helpful to me as I was changing references in recorded macros by hand. Is there a way to make this the default? I didn't see it in the Options (2010 version) and when I attempted to capture it in a recorded macro, there was nothing there. Thanks, Chester Hood
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2023 Sharon Parq Associates, Inc.
Comments