ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create a collection of ranges (https://www.excelbanter.com/excel-programming/380469-re-create-collection-ranges.html)

Dana DeLouis

Create a collection of ranges
 
What I would like to do is:
For Each r in rColl


Hi. Just throwing this out. Is the "Areas" the property you were looking
for?

Sub Demo()
Dim RngColl As Range
Dim r As Range
Set RngColl = Range("A1:D1, E40:R40, T120:AA120")

For Each r In RngColl.Areas
r.Select 'or Clear, or whatever...
Next
End Sub

--
Dana DeLouis
Windows XP & Office 2003


"Gary''s Student" wrote in message
...
What is the syntax to create a collection of ranges? Currently I use an
array of strings:

Sub dural()
s = Array("A1:D1", "E40:R40", "T120:AA120")
For i = LBound(s) To UBound(s)
Range(s(i)).Clear
Next
End Sub

What I would like to do is:

rColl = whatever
dim r as Range
For Each r in rColl
r.Clear
Next
--
Gary''s Student





All times are GMT +1. The time now is 08:50 PM.

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