How hold multiple versions of the same range?

J

John

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
 
J

Joel

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")
 
J

John

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
 
J

John

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
 
J

Joel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top