Macro VBA - Use relative references

SNoor

New Member
Joined
Mar 10, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

May I know why when i am creating the macro and then I click on "use relative reference" and the range will always at ("A1")?

ActiveCell.Offset(1, 0).Range("A1").Select

Thank you
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
May I know why when i am creating the macro and then I click on "use relative reference" and the range will always at ("A1")?

ActiveCell.Offset(1, 0).Range("A1").Select
Welcome to the Board!

Note that is really not doing what you think it is. It is not referencing the exact range "A1".

Notice how it starts from ActiveCell, which is whatever cell your cursor is currently in when you start the macro.
Then, the Offset command is moving one row down from there.
Then, the Range("A1") part is just telling it to select the first cell in the selected range (not necessarily cell A1).
So if you started in cell C8 when you ran this macro, it would select cell D8 (not cell A1).

Try it for yourself and see.
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top