title: VBA Remove Duplicates Error
body: <p>So, I am trying to delete any rows that have duplicate data in column A. I thought this was pretty elegant compared to some of the loops I saw people asking about. However, I get an error on the line rng.RemoveDuplicates Columns:=1, Header:=xlYes. The error is Run-time error 1004. Application defined or object defined error. </p>
  
  <p>Ideally, we can get the error to go away while also removing duplicates rows. Any help would be appreciated! Thanks! </p>
  
  <pre><code>Private Sub RemoveDuplicate_Click()
  
    Dim LastRow As Long
    Dim rng As Range
    Dim ws As Worksheet
    Set ws = Worksheets("Scorecard")
  
    LastRow = ws.Range("A" &amp; Rows.Count).End(xlUp).Row
    Set rng = ws.Range("A1:K" &amp; LastRow)
    rng.RemoveDuplicates Columns:=1, Header:=xlYes
  End Sub
  </code></pre>
  
  <p>Also, I tried this code as well and got the same error.</p>
  
  <pre><code>Private Sub RemoveDuplicate_Click()
  
   Dim LastRow As Long
   Dim rng As Range
   Worksheets("Scorecard").Activate
   LastRow = ActiveSheet.Range("A" &amp; Rows.Count).End(xlUp).Row
   Set rng = ActiveSheet.Range("A1:K" &amp; LastRow)
   rng.RemoveDuplicates Columns:=1, Header:=xlYes
  
  End Sub
  </code></pre>