ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How hold multiple versions of the same range? (https://www.excelbanter.com/excel-programming/417006-how-hold-multiple-versions-same-range.html)

John[_19_]

How hold multiple versions of the same range?
 
I want to save multiple possibilities for a range and be able to pop one
back into the range. Is there a way to do this other than saving the
ranges to an array? Can't use copy, paste because there are more than one.

Have Myrange = (Cells(1,1),cells(70,70))

then have 6 different versions of myrange.

thanks
John

joel

How hold multiple versions of the same range?
 
Uh!
set Myrange = Range(Cells(1,1),cells(70,70))

You decaration actually put data into the array MyRange, my method just sets
a point to the range.


Dim MyRange(6) as range
set Myrange(0) = Range(Cells(1,1),cells(70,70))
set Myrange(1) = Range(Cells(71,1),cells(140,70))
set Myrange(2) = Range(Cells(141,1),cells(210,70))
set Myrange(3) = Range(Cells(211,1),cells(280,70))
set Myrange(4) = Range(Cells(281,1),cells(350,70))
set Myrange(5) = Range(Cells(351,1),cells(420,70))

Myrange(5).copy destination:=sheets("Sheet2").Range("A1")



"John" wrote:

I want to save multiple possibilities for a range and be able to pop one
back into the range. Is there a way to do this other than saving the
ranges to an array? Can't use copy, paste because there are more than one.

Have Myrange = (Cells(1,1),cells(70,70))

then have 6 different versions of myrange.

thanks
John


John[_19_]

How hold multiple versions of the same range?
 
Thanks. I didn't know how to do that .copy destination thing. I was
saving in sdt myranr(2) = then didn't know how to get it back on the
worksheet.

John

Joel wrote:
Uh!
set Myrange = Range(Cells(1,1),cells(70,70))

You decaration actually put data into the array MyRange, my method just sets
a point to the range.


Dim MyRange(6) as range
set Myrange(0) = Range(Cells(1,1),cells(70,70))
set Myrange(1) = Range(Cells(71,1),cells(140,70))
set Myrange(2) = Range(Cells(141,1),cells(210,70))
set Myrange(3) = Range(Cells(211,1),cells(280,70))
set Myrange(4) = Range(Cells(281,1),cells(350,70))
set Myrange(5) = Range(Cells(351,1),cells(420,70))

Myrange(5).copy destination:=sheets("Sheet2").Range("A1")



"John" wrote:

I want to save multiple possibilities for a range and be able to pop one
back into the range. Is there a way to do this other than saving the
ranges to an array? Can't use copy, paste because there are more than one.

Have Myrange = (Cells(1,1),cells(70,70))

then have 6 different versions of myrange.

thanks
John


John[_19_]

How hold multiple versions of the same range?
 
Nope... that doesn't work. I wasn't clear. I want to save
(Cells(1,1),cells(70,70)). Then I won't to work with those ceslls and if
the work process doesn't work I want to restore those cells back to the
beginning. It is like having a backup of the cells to restore.

If have set Myrange = range(cells(1,1),cells(1,70)) then whatever
happens in those cells happens in Myrange so it can't be used as a
backup. that's my problem.

I suppose I could just use sheet2 for backup but it seems an expensive
way rather than in an array.

John


Joel wrote:
Uh!
set Myrange = Range(Cells(1,1),cells(70,70))

You decaration actually put data into the array MyRange, my method just sets
a point to the range.


Dim MyRange(6) as range
set Myrange(0) = Range(Cells(1,1),cells(70,70))
set Myrange(1) = Range(Cells(71,1),cells(140,70))
set Myrange(2) = Range(Cells(141,1),cells(210,70))
set Myrange(3) = Range(Cells(211,1),cells(280,70))
set Myrange(4) = Range(Cells(281,1),cells(350,70))
set Myrange(5) = Range(Cells(351,1),cells(420,70))

Myrange(5).copy destination:=sheets("Sheet2").Range("A1")



"John" wrote:

I want to save multiple possibilities for a range and be able to pop one
back into the range. Is there a way to do this other than saving the
ranges to an array? Can't use copy, paste because there are more than one.

Have Myrange = (Cells(1,1),cells(70,70))

then have 6 different versions of myrange.

thanks
John


joel

How hold multiple versions of the same range?
 
there are lots of trade-off you make when programming. The trade offs
include memory as well as time to execute. It is ineffiecient to move data
into an array and then not use the array data. Memory is cheap these days
and storing data in the spreadsheet is better than to move data into an array
which uses execution time.

"John" wrote:

Nope... that doesn't work. I wasn't clear. I want to save
(Cells(1,1),cells(70,70)). Then I won't to work with those ceslls and if
the work process doesn't work I want to restore those cells back to the
beginning. It is like having a backup of the cells to restore.

If have set Myrange = range(cells(1,1),cells(1,70)) then whatever
happens in those cells happens in Myrange so it can't be used as a
backup. that's my problem.

I suppose I could just use sheet2 for backup but it seems an expensive
way rather than in an array.

John


Joel wrote:
Uh!
set Myrange = Range(Cells(1,1),cells(70,70))

You decaration actually put data into the array MyRange, my method just sets
a point to the range.


Dim MyRange(6) as range
set Myrange(0) = Range(Cells(1,1),cells(70,70))
set Myrange(1) = Range(Cells(71,1),cells(140,70))
set Myrange(2) = Range(Cells(141,1),cells(210,70))
set Myrange(3) = Range(Cells(211,1),cells(280,70))
set Myrange(4) = Range(Cells(281,1),cells(350,70))
set Myrange(5) = Range(Cells(351,1),cells(420,70))

Myrange(5).copy destination:=sheets("Sheet2").Range("A1")



"John" wrote:

I want to save multiple possibilities for a range and be able to pop one
back into the range. Is there a way to do this other than saving the
ranges to an array? Can't use copy, paste because there are more than one.

Have Myrange = (Cells(1,1),cells(70,70))

then have 6 different versions of myrange.

thanks
John




All times are GMT +1. The time now is 05:01 AM.

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