Assume I selected the range A1:B2,C3:C5
.
Using VBA, I can loop through each area like this:
Dim iArea As Range
For Each iArea In Application.Selection.Areas
Debug.Print iArea.Address
Next iArea
I am able to return each range's address, in this case $A$1:$B$2
and $C$3:$C$5
.
How can I refer to the 2nd area in a range, or better yet, the nth area? I can refer to the nth cell in a range using Range.Cells(cellNumberToReturn)
. Is something similar for ranges?
Just use indexer: