ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do you have range address (https://www.excelbanter.com/excel-programming/343379-how-do-you-have-range-address.html)

Mike[_101_]

How do you have range address
 
I need to have the user select a range of cells, click a button to run a
macro, select another range and click another button to run another macro.

I need to save the address of the original range that was selected for
reference in the second macro. What would be the command syntax to save the
address of the initial range so I can reference it again.



Gary''s Student

How do you have range address
 
Dim firstrange as range
..
..
..
set firstrange = Selection

Just remember to dim the variable in the module outside of both macros.
That way it will be static and not loose its value once the first macro exits
--
Gary''s Student


"Mike" wrote:

I need to have the user select a range of cells, click a button to run a
macro, select another range and click another button to run another macro.

I need to save the address of the original range that was selected for
reference in the second macro. What would be the command syntax to save the
address of the initial range so I can reference it again.




Mike[_101_]

How do you have range address
 
That does what I needed.

Thanks!!!


"Gary''s Student" wrote in message
...
Dim firstrange as range
.
.
.
set firstrange = Selection

Just remember to dim the variable in the module outside of both macros.
That way it will be static and not loose its value once the first macro
exits
--
Gary''s Student


"Mike" wrote:

I need to have the user select a range of cells, click a button to run a
macro, select another range and click another button to run another
macro.

I need to save the address of the original range that was selected for
reference in the second macro. What would be the command syntax to save
the
address of the initial range so I can reference it again.







All times are GMT +1. The time now is 03:33 PM.

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