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.
Written by Allen Wyatt (last updated March 28, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003
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.
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!
Troubleshooting an Excel macro when it causes the entire computer to freeze can be a tedious affair. This tip provides ...Discover More
Excel keeps track of the actions you take so that you can undo those actions if any are taken in error. You may want to ...Discover More
An Excel workbook can contain quite a few different objects. Sometimes those objects can be hidden so that they are not ...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.