ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Relativity with a macro (https://www.excelbanter.com/excel-discussion-misc-queries/133077-relativity-macro.html)

Mary jane

Relativity with a macro
 
If I create a macro to automatically print a total row, and then I manipulate
that row i.e. move it, add columns, whatever, will the macro adjust to all
changes and run correctly?

Thanks

Alan

Relativity with a macro
 
No it won't unfortunately, if you tell it to print a defined area like A1:C1
it will do just that, you would have to manually change the code,
Regards,
Alan
"Mary jane" wrote in message
...
If I create a macro to automatically print a total row, and then I
manipulate
that row i.e. move it, add columns, whatever, will the macro adjust to all
changes and run correctly?

Thanks



Dave F

Relativity with a macro
 
It will if you create a dynamic named range and reference that named range in
the macro.
Info on dynamic named ranges he
http://www.ozgrid.com/Excel/DynamicRanges.htm

Dave

--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"Mary jane" wrote:

If I create a macro to automatically print a total row, and then I manipulate
that row i.e. move it, add columns, whatever, will the macro adjust to all
changes and run correctly?

Thanks


M. Authement

Relativity with a macro
 
No it will not. You will need to use a named range, Indirect, or Offset
(there may be other options as well, but one of those three should work).


"Mary jane" wrote in message
...
If I create a macro to automatically print a total row, and then I
manipulate
that row i.e. move it, add columns, whatever, will the macro adjust to all
changes and run correctly?

Thanks




joel

Relativity with a macro
 
Did you create a Sub or a Function? If you have only one value that is
returned, then it is best to use the Function rather than a sub. I would be
best if you had a function where you referenced the cell by passing them into
the functions as parameters. then everything would be updated as you changed
you spreadsheet.

"Mary jane" wrote:

If I create a macro to automatically print a total row, and then I manipulate
that row i.e. move it, add columns, whatever, will the macro adjust to all
changes and run correctly?

Thanks


Alan

Relativity with a macro
 
That true of course, but as I understood the original question, it was can
you set up a code event which will change the ranges set in the code to
accommodate changes in the worksheet regarding altering the range it refers
to.
You cant in VB, and if you need to alter a named range then what's the
difference? It still won't change, you have to alter it manually,
Regards,
Alan.
"Dave F" wrote in message
...
It will if you create a dynamic named range and reference that named range
in
the macro.
Info on dynamic named ranges he
http://www.ozgrid.com/Excel/DynamicRanges.htm

Dave

--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"Mary jane" wrote:

If I create a macro to automatically print a total row, and then I
manipulate
that row i.e. move it, add columns, whatever, will the macro adjust to
all
changes and run correctly?

Thanks




All times are GMT +1. The time now is 08:32 PM.

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