Try this
Sub Test()
Dim N As Long
For N = 3 To Sheets("Sheet1").Cells(Rows.Count, 4).End(xlUp).Row
If Sheets("Sheet1").Rows.RowHeight > 0 Then
If Sheets("Sheet1").Cells(N, 12) = "D7140" Or Sheets("Sheet1").Cells(N, 12) = "D7210" Then
If (Sheets("Sheet1").Cells(N, 13) >= 1 And Sheets("Sheet1").Cells(N, 13) <= 8) Or (Sheets("Sheet1").Cells(N, 13) >= 9 And Sheets("Sheet1").Cells(N, 13) <= 16) Or (Sheets("Sheet1").Cells(N, 13) >= 17 And Sheets("Sheet1").Cells(N, 13) <= 24) Or (Sheets("Sheet1").Cells(N, 13) >= 25 And Sheets("Sheet1").Cells(N, 13) <= 32) Then
If WorksheetFunction.CountIf(Sheets("Sheet2").Columns(4), Sheets("Sheet1").Cells(N, 4)) < Sheets("Sheet2").Cells(4, 2) Then
Sheets("Sheet2").Cells(Rows.Count, 4).End(xlUp).Offset(1, 0) = Sheets("Sheet1").Cells(N, 4)
Sheets("Sheet2").Cells(Rows.Count, 4).End(xlUp).Offset(0, 6) = Sheets("Sheet1").Cells(N, 12)
Sheets("Sheet2").Cells(Rows.Count, 4).End(xlUp).Offset(0, 7) = Sheets("Sheet1").Cells(N, 13)
End If
End If
End If
End If
Next N
End Sub
Bookmarks