Below is something that I experienced a while ago and was beyond my logic.
Setting a range and looping through all cells in it didn't work initially as expected.
Sub WeirdCelLooping()
Dim rngCel
As Range
Dim rngSelection
As Range
Range("A1:G10").Select
' Doesn't work correctly:
For Each rngCel In Selection.Columns(1)
' both rngCel and the selection have now the same address
Debug.Print rngCel.Address & " as part of " & Selection.Columns(1).Address
Next
' Doesn't work correctly:
Set rngSelection = Selection.Columns(1)
For Each rngCel In rngSelection
' both rngCel and the selection now still have the same address
Debug.Print rngCel.Address & " as part of " & Selection.Columns(1).Address
Next
' Does work correctly:
Set rngSelection = Range(Selection.Columns(1).Address)
For Each rngCel In rngSelection
' finally we can loop through each cell in the range
Debug.Print rngCel.Address & " as part of " & Selection.Columns(1).Address
Next
End Sub
Update October 24:
As stated in the comments below (thank!); the best practice to loop through a range is to explicitly add the .Cells at the end for the range:
Selection.Columns(1).Cells
rngSelection.Cells