Home > Enterprise >  Range Object: Rows.EntireRow vs EntireRow
Range Object: Rows.EntireRow vs EntireRow

Time:07-24

Is it any difference between the two codes below?

Code 1:
...
'rg1 is some Range Object
dim rg2 as Range
set rg2 = rg1.Rows.EntireRow
...
Code 2:
...
'rg1 is some Range Object
dim rg2 as Range
set rg2 = rg1.EntireRow
...

CodePudding user response:

No - you can check it with this code:

Sub test()
Dim rg1 As Range: Set rg1 = Selection

Dim rg2 As Range
Set rg2 = rg1.Rows.EntireRow

Dim rg3 As Range
Set rg3 = rg1.EntireRow

Debug.Print "rg2: " & rg2.Address, "rg3: " & rg3.Address

End Sub

result will be e.g. rg2: $6:$9 rg3: $6:$9 if C6:C9 is selected

  • Related