Relative References in Excel Macros
Last Updated :
06 Dec, 2023
We have two options to refer a cell in Excel VBA Absolute references and Relative references. Default Excel records macro in Absolute mode.
In this article, we learn about Relative references in Excel VBA. We select a cell “A1”, turn on “Use Relative Reference” and record a macro to type some text in cells B2:B4.
Since we turn on the “Relative reference” option. Macro considers the number of rows and columns from active cells. In our example, we select cell A1 and start type B2, which is to move one column and one row from A1 (Active cell).
What are Relative References?
In Excel, the way of recording actions within a macro that is relative to the cell or range that the macro starts from is known as a relative reference. When you start recording a macro with relative reference, Excel records the actions based on the position of the active cell at the beginning of the macro. The recorded actions will adjust accordingly when the macro is run on different ranges.
Using Relative References
We must make sure that the macro is recorded starting from the cell where the steps must begin in order to record a macro with relative references.
Implementation
Follow the below steps to implement relative reference in Excel Macros:
Step 1. Open Excel and Select Cell “A1”.
Note: The macro will place whatever you recorded on the same worksheet in the same location if you do not create a new worksheet before running it. You do not want this. Every report needs to be on a different worksheet.
Recording a Macro
The Record Macro command, located on the ribbon under the VIEW tab Macros, allows you to begin recording the macro.
Step 2. Go to “Developer” Tab >> Press “Use Relative References” >> Click “Record Macro”

Step 3. Enter the Macro name “relativeReference” and Press “OK”.

Step 4. Type “Australia” in cell B2
Step 5. Type “Brazil” in cell B3
Step 6. Type “Mexico” in cell B4
Stop recording the macro
Either use the Stop Recording command located on the ribbon under the VIEW tab Macros or click the Stop Recording Macro button located on the left side of the Excel taskbar to stop recording the macro.
Step 7. Select cell B5 and Press “Stop Recording”

VBA Code (Recorded)
Sub relativeReference()
ActiveCell.Offset(1, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "Australia"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "Brazil"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "Mexico"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub
Step 8. You just delete the contents in cells B2:B4, Select Cell B1.
Step 9. Go to View >> Macros >> View Macros – to popup Macro dialog box [keyboard shortcut - Alt+F8].

Running a Macro
Simply by running the macro, you may create any number of reports in a matter of seconds.
Step 10. Select Macro from the list (eg. relative reference) and Press “Run”.

Output
The active cell is B1 and runs the macro. So, the outputs (C2:C4) are placed in one row and one column from the active cell B1.

Reasons for Relative Reference Not Working
In Excel, relative referencing occasionally fails to function. The "Use Relative References" function being disabled is one potential explanation for relative referencing not being functional.
Solution
To fix the issue, press the "Use Relative References" button from the Developer menu before carrying out any actions.

I covered Excel Macro Relative Reference in this post. Hopefully, it would benefit everyone. I advise you to read more articles on Excel if you want to understand more. I appreciate your time and look forward to hearing from you soon!
Similar Reads
Absolute References in Excel Macros
Excel Macros are incredibly powerful tools that provide the capability to automate repetitive tasks, streamline processes, and save time. When building macros, it's common to use cell references for performing calculations or actions. In some situations, it's important to ensure that these reference
5 min read
Mixed Reference in Excel
A cell reference or a cell address is a way to define a cell on a worksheet, it is formed by combining a column letter and a row number. To refer any if the cell on a worksheet (in any formula/ to copy the cell) we use cell reference. Example: To refer to the cell present in row 2 & column D, ce
3 min read
Relative, Absolute and Mixed Cell Reference in Excel
Understanding how cell references in Excel work is a cornerstone of effective spreadsheet use. Whether youâre building formulas that auto-adjust to changes, locking a specific cell, or creating dynamic worksheets, the types of cell referencesârelative, absolute, and mixedâplay a vital role. This gui
11 min read
Excel Relative and Absolute Cell References
When working with formulas in Excel, it's crucial to understand the difference between relative and absolute cell references. These two types of cell references behave differently when copied or filled into other cells. Relative cell references change based on their position when a formula is copied
8 min read
UserForms in Excel Macros
A UserFrom refers to a form or a dialog box on the screen that enables a user to input data into Excel's user interface. it can be created using the Visual Basic Editor and is used to control data entry and avoid errors. 1. Creating a UserForm: To create a userform head on to the Developer tab->
5 min read
Mixed Cell References in MS Excel
Cell: The row and column in Excel together make a cell. We input the value/data(s) in cells of a spreadsheet. There are three types of values that can be entered into the cell. NumbersAlphabeticFormulas Cell reference ââââââis the address or name of a cell or a range of cell is known as Cell referen
3 min read
How to Record a Macro in Excel
Excel Macro is simply a record button that records a set of actions performed on Excel that can be run multiple times. For example, if you have to format some raw data on a weekly basis you can use a macro to record yourself formatting the data once and let Excel automate the task in the future. it'
11 min read
How to Find Circular References in Excel
Circular Reference in Excel is like a loop that keeps going around in circles. It happens when a cell's formula depends on its own result, confusing Excel. In this article, you'll learn how to check, find, enable, or remove Find Circular References in Excel What is a Circular Reference in Excel?A ci
7 min read
Microsoft Excel Templates
Excel Templates are used to increase the overall productivity of an individual or organization. These templates allow us to perform and optimize our spreadsheet in a very enhanced way even if we have a very basic understanding of excel spreadsheets. These templates are of several categories which wi
2 min read
Sub Procedure in Excel VBA
A Sub Procedure is an action that is written in VBA code. It starts with a Sub statement and ends with an End Sub statement. It is used to manipulate the data in an Excel sheet which includes a table present in an Excel sheet or a pivot table present in the Excel sheet. The name of the procedure sho
3 min read