Non Contiguous range and loops
c = 1
for each cell in rng
myArray(c) = cell.row
c = c + 1
Next
-----------------
rng.cells(c)
is an offset from the top left cell in the range.
--
Regards,
Tom Ogilvy
"David" wrote in message
...
The following code returns 1 ,2 , 3, and 4 for the row
numbers of the non contiguous range rng.
Sub Code1 ()
Dim rng As Range
Set rng = Range("A1,A5,A7,A12")
For c = 1 To 4'
myArray(c) = rng.Cells(c).Row
Next
End Sub
|