title: Remove Duplicates in VBA excel
body: <p>I am trying to remove the duplicates at the end of a macro I wrote in vba.  The macro runs but when it comes to the point to remove the duplicates it says that the object doesn't support the property or method when the object is Dimed as a range and set as a range as well.  I am really confused on why this happening and I can't seem to spot what is causing this error. I have pasted the code below which causes the error and the point where I set the range object. Any help would be greatly appreciated. </p>
  
  <pre><code>Set WS = ThisWorkbook.ActiveSheet
      With WS
          Set Rng1 = .Range("B2:B" &amp; .Range("B" &amp; .Rows.Count).End(xlUp).Row)
          Set rng2 = .Range("C1:D" &amp; .Range("C" &amp; .Rows.Count).End(xlUp).Row)
      End With
  
  If UBound(WrdArray2) &lt; 0 Then
      ActiveSheet.rng2.RemoveDuplicates
          End
  End If
  </code></pre>