I need this code to search through a table in sheet1 and copy across the rows which match a certain criteria,
any tips on where I am going wrong?
Sub find_orders()
Application.ScreenUpdating = False
Dim r As Long, endRow As Long, pasteRowIndex As Long
endRow = Sheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Row
pasteRowIndex = 2
For r = 2 To endRow
    If Cells(r, 6) = "d" Then
        Range(Cells(r, 2), Cells(r, 6)).Copy
        Sheets("sheet2").Select
        Range(Cells(pasteRowIndex, 2), Cells(pasteRowIndex, 6)).Select
        pasteRowIndex = pasteRowIndex + 1
        Sheets("sheet1").Select
        End If
Next r
End Sub
 
     
     
    