K
Kieran
Greetings all -
My problem is one of understanding or lack of it! :
I wish to loop through the first column of a range. I set a range
object to equal the first column of my range. I then attempt to loop
through each cell in my now - single column range. Yet for reasons I
don't understand my Cell range is now the same as rRange and the
process fails
Sub xx()
Dim Cell As Range
Dim rRange As Range
Set rRange = Range("A1:B20").Columns(1)
For Each Cell In rRange
Debug.Print Cell.Address
Next
End Sub
However if I do the following it works perfectly
Sub x()
Dim Cell As Range
Dim rRange As Range
Set rRange = Range("A1:B20").Columns(1)
For Each Cell In Range(rRange.Address)
Debug.Print Cell.Address
Next
End Sub
Any thoughts would be appreciated - note that I am keen to understand
the issue not solve it another way
Cheers
Kieran
My problem is one of understanding or lack of it! :
I wish to loop through the first column of a range. I set a range
object to equal the first column of my range. I then attempt to loop
through each cell in my now - single column range. Yet for reasons I
don't understand my Cell range is now the same as rRange and the
process fails
Sub xx()
Dim Cell As Range
Dim rRange As Range
Set rRange = Range("A1:B20").Columns(1)
For Each Cell In rRange
Debug.Print Cell.Address
Next
End Sub
However if I do the following it works perfectly
Sub x()
Dim Cell As Range
Dim rRange As Range
Set rRange = Range("A1:B20").Columns(1)
For Each Cell In Range(rRange.Address)
Debug.Print Cell.Address
Next
End Sub
Any thoughts would be appreciated - note that I am keen to understand
the issue not solve it another way
Cheers
Kieran