Ensuring Absolute 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 absolute references.

Implementation

Follow the below steps to implement Absolute references 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. 

On the left side of the Excel taskbar, there is a button that says “Start Recording Macro” which you can also use.

Step 2: Go to the “Developer” Tab >> Click “Record Macro

Give the macro a name that will help others recognize it as a report for a certain project.

Step 3: Enter the Macro name absolute Reference and Press “OK”

Your macro begins to record

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.

Click on cell B5. This makes sure that the macro always records your steps in B5.

Step 7: Select cell B5 and Press “Stop Recording”

VBA Code (Recorded)

Sub absoluteReference()

    Range(“B2”).Select

    ActiveCell.FormulaR1C1 = “Australia”

    Range(“B3”).Select

    ActiveCell.FormulaR1C1 = “Brazil”

    Range(“B4”).Select

    ActiveCell.FormulaR1C1 = “Mexico”

    Range(“B5”).Select

End Sub

Step 8: We can just delete the contents in cells B2:B4

Step 9: Go to View >> Macros >> View Macros – to pop-up Macro dialogue 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: On the Ribbon, select the VIEW button and Click Macros 

Step 11: Select a Macro from the list (e.g. absolute Reference) and Press “Run”

Output

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 references remain fixed, no matter where the macro is applied or copied. Here the absolute reference plays an important role.

We have two options to refer a cell in Excel VBA Absolute references and Relative references.  Default Excel records macro in Absolute mode.

Both absolute references and relative references can be used while recording Excel macros. Regardless of the active cell, a macro recorded using absolute references places the recorded steps exactly in the cells where it was recorded. However, a macro that has been recorded with relative references can carry out the activities at several locations on the worksheet.

In this article, we will learn about absolute references in Excel VBA. We record a macro to type some text in cells B2:B4.  Macro always types the text in the cells B2:B4, irrespective of the active cell.

Similar Reads

Ensuring Absolute 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 absolute references....

Importance of Absolute Reference in Excel Macros

Following are some points:...

FAQs on Absolute Reference in Excel Macros

Q1. Which form is preferable, absolute or relative?...

Contact Us