Copy filtered rows to another sheet
<p>I want to copy the filtered row to another sheets but getting an error on below code. I have three status in column E i.e Open, Close and Overdue. I want to copy all the rows having status as open or overdue.</p>

<p>Error occurred at the below line</p>

<pre><code>.AutoFilter Field:=5, Criteria1:="open"
</code></pre>

<p>Here's the code</p>

<pre><code>Dim Wb As Workbook
Dim ws As Worksheet
Set Wb = Workbooks.Open(TextBox2.Text)
Set ws = Wb.Sheets(strSheetName)

With ws
    .AutoFilterMode = False
    With .Range("A1:E65536")
        .AutoFilter Field:=5, Criteria1:="open"
        .SpecialCells(xlCellTypeVisible).copy Destination:=Sheets("Master Records").Range("A1")
    End With
End With
</code></pre>

<p>Well, since I'm new I didn't say what was the error, nor where the input workbook where coming from... So maybe my users give me ill formatted stuff, without filter in the sheet that should be...</p>