ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I turn on relative reference(?) in a macro (97ver had butto (https://www.excelbanter.com/excel-programming/350048-how-do-i-turn-relative-reference-macro-97ver-had-butto.html)

Bernina27

How do I turn on relative reference(?) in a macro (97ver had butto
 
In the 97 version of Excel you could click the relative reference button (I
think that is what it was called) and the macro would recognize and update
itself automatically if the spreadsheet itself changed after the macro was
created. (i.e. vb programming says select cell B2 and clear the contents, you
insert a row above row B, so B2 is now B3 but your macro still wants to clear
B2.)

How do you do this in Excel 2003?
Thanks.


Jim Thomlinson[_5_]

How do I turn on relative reference(?) in a macro (97ver had butto
 
There is no way to reference as you describe. The code will have no idea that
at some point prior to exectution that the sheet was changed (row inserted).
Right on the Macro record toolbar there is a button for relative referencing
but that will not do what you have described here. The way to do that would
be to make Cell B2 a named range. Then when you record the macro it will
reference the named range which will move as you insert rows or such thereby
keeping your macro working as intended.
--
HTH...

Jim Thomlinson


"Bernina27" wrote:

In the 97 version of Excel you could click the relative reference button (I
think that is what it was called) and the macro would recognize and update
itself automatically if the spreadsheet itself changed after the macro was
created. (i.e. vb programming says select cell B2 and clear the contents, you
insert a row above row B, so B2 is now B3 but your macro still wants to clear
B2.)

How do you do this in Excel 2003?
Thanks.



All times are GMT +1. The time now is 10:16 PM.

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