ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array of Range Objects (https://www.excelbanter.com/excel-programming/412330-array-range-objects.html)

ExcelMonkey

Array of Range Objects
 
Is it possible to create an array of range objects? I have used the Set stmt
for range objects (Example #1). Is it possible to set up many rang objects
in an array and use the Set stmt on this array(Example #2)? If so how would
you dimension the array?

Example #1
Set rng = ........

Example#2
For X = 0 to 10
Set RngArray(0) = .....
Next

Jim Thomlinson

Array of Range Objects
 
You could set up your array to hold variants which will allow for ranges but
a collection is generally a little easier when you want to store a group of
objects. Something like this...

Sub test()
Dim colRanges As Collection
Dim rng

Set colRanges = New Collection
With colRanges
.Add Range("A1:A10")
.Add Range("B1:B10")
.Add Range("C1:C10")
End With

For Each rng In colRanges
MsgBox rng.Address
Next rng
End Sub
--
HTH...

Jim Thomlinson


"ExcelMonkey" wrote:

Is it possible to create an array of range objects? I have used the Set stmt
for range objects (Example #1). Is it possible to set up many rang objects
in an array and use the Set stmt on this array(Example #2)? If so how would
you dimension the array?

Example #1
Set rng = ........

Example#2
For X = 0 to 10
Set RngArray(0) = .....
Next



All times are GMT +1. The time now is 01:22 PM.

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