title: VBA AutoFilter Runtime Error 1004: AutoFilter method of Range class failed
body: <p>My code is as follows, it throws this error for the last line of statement before End Sub. Can someone advise what the problem may be?</p>
  
  <pre><code>    Sub Copy()
  
      Set target_book = ActiveWorkbook.Sheets("Sheet2")
      ActiveWorkbook.Sheets("Sheet1").Activate
      last_row_2 = ActiveSheet.Range("B100000").End(xlUp).Row
  
      For k = 2 To last_row_2
          ActiveWorkbook.Sheets("Sheet1").Activate
          Range("A" &amp; k &amp; ":Y" &amp; k).Select
          Selection.Copy
          target_book.Select
          last_row = target_book.Range("B100000").End(xlUp).Row
          target_book.Range("B" &amp; last_row + 1 &amp; ":Z" &amp; last_row + 1).Select
          Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
          Application.CutCopyMode = False
      Next k
  
      target_book.Activate
      ActiveSheet.Range("A13:Z13").AutoFilter Field:=5, Criteria1:="&lt;&gt;", 
      VisibleDropDown:=True
  
      End Sub
  </code></pre>