ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I change a macro to use relative cell addresses? (https://www.excelbanter.com/excel-discussion-misc-queries/37878-how-do-i-change-macro-use-relative-cell-addresses.html)

Roger D

How do I change a macro to use relative cell addresses?
 
When I record a macro, it uses absolute cell addresses. How do I change the
macro to run from a specific cell and relative to that cell?

Don Guillett

try
activecell.offset(1,2)

However, I suspect you are using a lot of SELECTIONS which usually aren't
necessary. Why not copy/paste your code here along with an explanation of
what you are trying to do.
--
Don Guillett
SalesAid Software

"Roger D" <Roger
wrote in message
...
When I record a macro, it uses absolute cell addresses. How do I change

the
macro to run from a specific cell and relative to that cell?




bornjuice

The only forms I know you can introduce relative references into a
Macro is....

a) using ActiveCell.Offset(R,C), where + is rows below or columns ahead
and - is rows above or columns before. Obviously you had to define R
and C before in the Macro or into the expression as a solid number.

b) sometimes works som others don=B4t...
Range with the cells method in this way:
Range(Cells(R,C)) or Range(Cells(Ri,Ci),Cells(Re,Ce)), where subscript
"i" referes to initial and "e" refres to end of a range of cells. Same
asumptions about relative references for each one as described before.

Hope it helps...

Alvaro Silva
TMMQ



Don Guillett wrote:
try
activecell.offset(1,2)

However, I suspect you are using a lot of SELECTIONS which usually aren't
necessary. Why not copy/paste your code here along with an explanation of
what you are trying to do.
--
Don Guillett
SalesAid Software

"Roger D" <Roger
wrote in message
...
When I record a macro, it uses absolute cell addresses. How do I change

the
macro to run from a specific cell and relative to that cell?




All times are GMT +1. The time now is 06:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com