For example, in the code below, Item
and Cells
can be used interchangeably:
Dim rRange As Range
Set rRange = ThisWorkbook.ActiveShe
The best way to understand this is via the below example
When .Item
and .Cells
are used with respect to a range then, YES, they are same. For example
Sub Sample()
Dim rRange As Range
Set rRange = ThisWorkbook.ActiveSheet.Range("B1:C10")
With rRange
Debug.Print .Item(1, 3).Address '<~~ $D$1
Debug.Print .Cells(1, 3).Address '<~~ $D$1
End With
End Sub
In the above they both depict the address of the cell in that Range
They are different when Cells()
is used independently of a range.
Sub Sample()
Dim rRange As Range
Set rRange = ThisWorkbook.ActiveSheet.Range("B1:C10")
With rRange
Debug.Print .Item(1, 3).Address '<~~ $D$1
'~~> DOT before Cells missing
Debug.Print Cells(1, 3).Address '<~~ $C$1
End With
End Sub
In the above .Item
depicts the address of the cell in that Range
, where as Cells
depicts the address of the cell in the ActiveSheet