Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Relative References when Recording Macros.
by Allen Wyatt
(last updated October 16, 2017)
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 using the Relative Reference tool on the Stop Recording toolbar. Click the tool and all your subsequent actions are interpreted relative to the current 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 tool before you take an action that is recorded. The tool's stated (on or off) affects only the recording of future actions, not what has been already recorded.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3108) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) 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!
One of the things you can do with macros is to work with disk files. As you do so, you may have a need to create a new ...Discover More
You can easily configure Excel so that it runs a specific macro whenever a worksheet is deactivated. Just follow the easy ...Discover More
The mouse wheel, by default, controls scrolling vertically through your worksheet. If you don't want the wheel to control ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.