Hi,
Try the following macro. The reason AB33 finds the looping macro slow when used with hundreds of rows is because each time through the loop VB code has to jump back to Excel and then jump back to the VB environment. There is a time overhead with each jump which is why loops should be avoided at all costs for this sort of stuff. The fastest way I know to achieve this is to use Excel's standard data filtering functionality. So:
Sub CopyNewParts()
Dim lLastrow As Long
lLastrow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
Sheet1.Range("AF1") = "NewPart"
Sheet1.Range("AF2") = "=IFERROR(MATCH(A2,'My Part Number'!A:A,FALSE),""New"")"
Sheet1.Range("AF2").Copy Destination:=Sheet1.Range("AF2:AF" & lLastrow)
Sheet1.Range("AF1").AutoFilter , Field:=32, Criteria1:="New"
If Sheet1.Range("A" & Rows.Count).End(xlUp).Row > 1 Then
Sheet1.Range("a1").CurrentRegion.SpecialCells(xlCellTypeVisible).Offset(1, 0).Resize(, 31).Copy
Sheet3.Range("A" & Rows.Count).End(xlUp).Cells(2, 1).PasteSpecial (xlPasteAll)
End If
Sheet1.Range("A1").AutoFilter
End Sub
Bookmarks