title: VBA - Different .address when assigning a range object with "Set" and "="
body: <p>I have this bit of code and I don´t understand this particular behavior:</p>
  <p>1.
  If I assign the range to rngSearch via 'Set' Keyword, than debug.print displays the result I expect: $P$1:$AI$1</p>
  <p>2.
  If I assign the range to rngSearch via '=' operator (and comment out 1.), than debug.print displays: $P$1</p>
  <p>Since in both I alwas refer to the same range .Range(.Cells(1, lnFirstCol), .Cells(1, lnLastCol)) I don´t understand how in 2. he doesn´t take it.
  I assume that he ignores the assignment and sticks with the first assignment.
  Can you please explain why it happens?
  Thank you!</p>
  <pre><code>Sub CreateFile()
  
  Dim NewBook         As Workbook
  Dim SheetToCopy     As String
  
  SheetToCopy = &quot;MasterVBATest&quot;
  
  ThisWorkbook.Sheets(SheetToCopy).Copy After:=Worksheets(&quot;Cockpit&quot;)
  ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
  
  Dim rngSearch As Range
  Dim lnFirstCol As Long
  Dim lnLastCol As Long
  Dim ValueToFind As Variant
  
  ValueToFind = &quot;Trenner&quot;
  
  With ActiveSheet
  
      lnLastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
      
      'First assignment
      Set rngSearch = .Range(.Cells(1, 1), .Cells(1, lnLastCol)).Find(What:=ValueToFind, LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext, MatchCase:=False)
      Debug.Print rngSearch.Address 'Result: $P$1 --&gt; expected
      If rngSearch Is Nothing Then
          Debug.Print ValueToFind &amp; &quot; was not found.&quot;
      Else
          lnFirstCol = rngSearch.Column
      End If
       
      '1.
      'Set rngSearch = .Range(.Cells(1, lnFirstCol), .Cells(1, lnLastCol))
      'Debug.Print rngSearch.Address ' Result: $P$1:$AI$1 --&gt; expected
      
      '2.
      rngSearch = .Range(.Cells(1, lnFirstCol), .Cells(1, lnLastCol))
      Debug.Print rngSearch.Address ' Result: $P$1
  
  End With
  </code></pre>
  <p>End Sub</p>