I stumbled across some unexpected behavior when writing an answer for this question.
When chaining together Range
calls, Address
always returns the address of the very first Range
object in the statement. For example:
Public Sub Unexpected()
Debug.Print Range("B3").Address
Debug.Print Range("B3").Range("A1").Address
End Sub
Returns the following output.
$B$3
$B$3
But I would have expected it to return the Address of the last Range object in the chain.
$B$3
$A$1
Can anyone explain this behavior? Preferably with a quote of and link to the appropriate documentation.
There is documentation on using
Range().Cells()
which indicates thatCells()
will return the location within the givenRange()
relative to the top left cell of theRange()
. Testing this theory withRange().Range()
gives:Documentation here: