Key Takeaways

  • Excel records macros in absolute mode by default, meaning the macro always returns to the same cell where it was originally recorded.
  • Turning on relative reference before recording makes the macro start from whatever cell is currently selected, making it far more flexible.
  • You toggle relative reference on and off using the Use Relative References button on the Developer tab.
  • The VBA code for a relative reference macro uses ActiveCell.Offset instead of fixed cell addresses like Range("A1").

What Is a Relative Reference in an Excel Macro?

By default, Excel records macros in absolute mode. In absolute mode, a macro will start working in the same cell it was in when it was recorded. If A1 was the active cell during recording, the macro will return to A1 and begin working from there no matter which cell was selected prior to starting the macro.

Excel Macro Relative Reference - Image 1

When you turn on relative reference before recording a macro, it will start the macro "relative" to whatever cell is currently selected. Instead of recording fixed cell addresses, Excel captures each action as an offset from the active cell. This makes the macro reusable across different locations in your worksheet and far more flexible for everyday tasks.

Understanding the difference between absolute and relative reference in an Excel macro is essential for building macros that work reliably no matter where you need them.

Absolute vs. Relative Reference at a Glance

Feature Absolute Reference Relative Reference
Default behavior On by default when recording Must be toggled on before recording
Starting cell Always returns to the exact cell used during recording Starts from whatever cell is currently selected
VBA code output Uses fixed addresses like Range("A1") Uses ActiveCell.Offset(row, column)
Best use case Tasks that must always target a specific cell or range Tasks you need to repeat in different locations across a worksheet

Example: Absolute vs. Relative Reference in Action

In this example, you start recording a macro in Cell A6 and record the action of inserting a row. Here is how the result differs depending on whether you use absolute or relative reference.

**1. With Absolute Reference**

With absolute reference, no matter which cell is selected when you run the macro, it will always insert a row at Row 6, because the macro recorded the exact cell address.

Excel Macro Relative Reference - Image 2

**2. VBA Code in Edit Mode (Absolute)**

The VBA code below shows how Excel recorded the action using a fixed cell reference.

Excel Macro Relative Reference - VBA Code 1

**3. With Relative Reference**

With relative reference, the macro inserts a row relative to whichever cell is currently selected. For example, if Cell A9 is selected, the macro will insert a row at Row 9.

Excel Macro Relative Reference - Image 3

**4. VBA Code in Edit Mode (Relative)**

The VBA code below shows how Excel recorded the same action using an offset from the active cell instead of a fixed address.

Excel Macro Relative Reference - VBA Code 2

**5. How to Toggle Relative Reference**

Click the Use Relative References button in the Code group on the Developer tab to toggle relative reference on and off. When the button appears highlighted, relative reference mode is active.

Troubleshooting: Why Relative Reference Is Not Working

If your relative reference macro is not behaving as expected, check for these common issues:

  • You toggled the button after recording started. The Use Relative References button must be clicked before you click Record Macro. If you toggle it mid-recording, only the steps recorded after the toggle will use relative references.
  • You mixed absolute and relative references unintentionally. If you toggled the button on and off during recording without realizing it, some steps may reference fixed cells while others use offsets. Review your VBA code for a mix of Range() and ActiveCell.Offset() commands.
  • The Developer tab is not visible. If you cannot find the Use Relative References button, you may need to enable the Developer tab first. Go to File > Options > Customize Ribbon and check the box next to Developer.
  • The active cell was not where you expected. A relative reference macro operates from whatever cell is selected when you run it. If the wrong cell is active, the macro will execute its offsets from that unexpected starting point. Always confirm your active cell before running the macro.

Tips for Using Relative References Effectively

  • Always verify the toggle state of the Use Relative References button before you start recording. The button stays in whatever state you last set it, even between recording sessions.
  • Plan your starting cell position before recording. Think through where the active cell needs to be so the offsets make sense when you run the macro from other locations.
  • Test your macro from multiple cells after recording. Run it from at least two or three different starting positions to confirm it behaves correctly everywhere.
  • Combine absolute and relative references intentionally by toggling the button during recording. This is useful when certain steps must always target a specific cell while other steps should adapt to the current position.
  • Use the Macro Recorder as a learning tool. After recording, open the VBA editor to see how Excel translated your actions into ActiveCell.Offset commands, then refine the code manually as needed.

Build Your Excel Skills with Pryor Learning

Mastering macros and relative references is just one step toward getting more out of Excel. Pryor Learning offers live seminars and on-demand courses that cover everything from foundational spreadsheet skills to advanced VBA programming. Explore Pryor's Excel training options to take your productivity to the next level.

Commonly Asked Questions

Click the Use Relative References button in the Code group on the Developer tab before you start recording your macro. When the button is highlighted, all actions you record will be captured as offsets from the active cell rather than fixed cell addresses. Once you click Record Macro and perform your steps, Excel will store each action relative to your starting position. 

An absolute reference macro always acts on the exact cells used during recording, while a relative reference macro acts on cells based on their position relative to the active cell when you run it. This means a relative reference macro can be reused from any starting cell in your worksheet without jumping back to the original recording location. 

The macro executes its recorded steps starting from whatever cell is currently selected, using offsets from that cell. For example, if you recorded the macro starting at A1 and run it from C5, all actions shift to start at C5 instead. This is what makes relative reference macros so flexible for repetitive tasks across different parts of a worksheet. 

The most common reason is that you toggled the button after you already started recording, so only part of your macro uses relative references. Make sure you click Use Relative References before clicking Record Macro. Also verify the Developer tab is enabled in your Excel ribbon settings by going to File > Options > Customize Ribbon. 

Yes, you can combine both reference types in a single macro by toggling the Use Relative References button on and off during the recording process. This is useful when you want certain steps to always target a specific cell (absolute) while other steps adapt to the current position (relative). Review your recorded VBA code afterward to confirm each step uses the intended reference type. 

ActiveCell.Offset is the VBA command Excel uses to record relative references, specifying a row and column offset from the currently selected cell. For example, ActiveCell.Offset(1, 0) means "move one row down from the active cell." This contrasts with absolute references, which use fixed addresses like Range("A1").