ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Storing multiple ranges using a macro (https://www.excelbanter.com/excel-discussion-misc-queries/199855-storing-multiple-ranges-using-macro.html)

Chaman

Storing multiple ranges using a macro
 
I have to play with lot of ranges in a worksheet. Say range1 is from
A1:A10, range2 is from B1:B10 and so on. I have 1000s of such
ranges.

One of doing it is defining individial ranges say

dim range1 as range
dim range2 as range
.....
....
....

etc.

I dont want to use 1000 variables for 1000 different ranges. Is there
any way of creating an array of ranges? OR Whats the best way of
doing it?

Per Jessen

Storing multiple ranges using a macro
 
Hi

Sure, you can use an array:

Sub Test()
Dim RangeArray(1000) As Range

For c = 0 To 999
Set RangeArray(c) = Range("A1:A10").Offset(0, c)
Next
End Sub

Regards,
Per
"Chaman" skrev i meddelelsen
...
I have to play with lot of ranges in a worksheet. Say range1 is from
A1:A10, range2 is from B1:B10 and so on. I have 1000s of such
ranges.

One of doing it is defining individial ranges say

dim range1 as range
dim range2 as range
....
...
...

etc.

I dont want to use 1000 variables for 1000 different ranges. Is there
any way of creating an array of ranges? OR Whats the best way of
doing it?




All times are GMT +1. The time now is 11:55 AM.

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