title: Excel VBA- Code suddenly get a runtime error 91 (AutoFilter)
body: <p>I have a code that will search and copy from one sheet to another by using autofiler. I included my code below. My problem here is that, earlier (2 weeks ago), the code worked just fine as intended, I've tested the code so many time and there is no error. Suddenly, there is runtime error 91 when I run the code, and the error seems to be with this line:</p>
  
  <pre><code>.AutoFilter.Range.Offset(1, 0).Copy Destination:=ws2.Range("B10")
  </code></pre>
  
  <p>I've tried the <code>.AutoFilter=False</code>, error handling and also worksheet activate. But I still get the same runtime error. Can someone help me figure out what is wrong with my code? any helps are much appreciated.         </p>
  
  <pre><code>Sub search()
      Dim ws1, ws2 As Worksheet
      Set ws1 = Worksheets("Master")
      Set ws2 = Worksheets("Fruit")
      'Worksheets("Fruit").Activate
  
      With ws1
          '.AutoFilterMode = False
          .Range("B7").AutoFilter
          .Range("B7").AutoFilter field:=17, Criteria1:="Rotten"
          'On Error Resume Next
          .AutoFilter.Range.Offset(1, 0).Copy Destination:=ws2.Range("B10")
          '.AutoFilterMode = False
      End With
  
      With ws2.Range("B10:Y1400").Borders
          .LineStyle = xlContinuous
          .Weight = xlThin
      End With
  
      MsgBox ("Search done.")
  End Sub
  </code></pre>