Absolute and Relative Macros?

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

kskinne

Well-known Member
Joined
Feb 17, 2002
Messages
1,267
Office Version
  1. 365
Platform
  1. Windows
i recently asked the same question in another post, and i assume you mean, is there a way to refer to a cell range in a macro so that if the location of that cell range changes, the reference to it in your code also changes automatically. as far as i know, the only way to do this would be to name your cell range in your sheet, then in your macro, use your range name instead of the cell reference to refer to you range.

HTH
kevin
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
If you record a macro you can choose between absolute and relative - there's a toggle button on the Recorder Toolbar.

In absolute mode the recorder refers to explicit ranges eg Range("A1:A10") (or Sheets or Charts). If you run the macro it does exactly what you did manually.

In relative mode the recorder uses ActiveCell and Offset (or ActiveSheet and ActiveChart). If you run the macro it does what you did manually, but relative to the active cell.

And you can adopt the same approach in non-recorded code.
 

Forum statistics

Threads
1,147,751
Messages
5,742,985
Members
423,771
Latest member
dimyak

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
Top