0 votes
in VBA by Beginner (123 points)
“Use Relative References “ in code group under Developer tab

1 Answer

0 votes
by Skilled (306 points)


With the Recording Macro approach I have recorded simple code to illustrate the difference to you

Sub Macro1()
' Macro1 Macro

    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveCell.FormulaR1C1 = "Yasser"
    ActiveCell.Offset(0, 1).Range("A1").Select
End Sub

Sub Macro2()
' Macro2 Macro

    ActiveCell.FormulaR1C1 = "Yasser"
End Sub

As you see, with activating the Relative Reference, the macro deal with any cell using Offset function. But without using it the macro records the cell reference in absolute reference using the cell addresses directly.

by Beginner (123 points)
Got it, thanks.

Another related question: OFFFSET is a volatile worksheet function.

Is OFFFSET also volatile when used in VBA code to say make a ToC in an excel  worksheet?
by Skilled (306 points)
That depends on the use of OFFSET. But I think it is different from the OFFSET volatile worksheet function.
by Beginner (123 points)

I believe that OFFFSET is not volatile when used in any VBA code.

by Skilled (306 points)
But use it for necessary purposes

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

What makes us different?
Our points system rewards you with a chance for free gifts as your contributions grow. The more points you earn, the better the prizes.

Getting Started

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.

Top Users Mar 2019
  1. YasserKhalil

    306 Points

  2. ParserMonster

    204 Points

  3. Alberto Semat

    186 Points

  4. danmcg

    127 Points

  5. Abdan

    124 Points

Prizes for March 2019
Terms and Conditions
1st place (1) 1-year MyExcelOnline Academy Membership
(2) My First Add-in Dev Pack & Course
(3) AutoMacro: VBA Code Generator (Developer)
(4) VBA Cheat Sheet Bundle
(5) $35 Amazon Gift Card
2nd place (1) My First Add-in Dev Pack & Course
(2) 101 Most Popular Excel Formulas E-Book
(3) VBA Cheat Sheet Bundle
(4) $25 Amazon Gift Card
3rd place (1) Mouse to Macro
(2) VBA Cheat Sheet Bundle
(3) $15 Amazon Gift Card