Hi, mhenry123,
use either WorksheetFunction.CountIf on your invoice number and only copy if the result is 0 or VLookup not returning #N/A. Assuming that the invoice number is in Column A, code is untested:
Sub Exporting_Data1_re()
Dim i As Long, LR As Long, X As Long, a, ms As Worksheet
Application.ScreenUpdating = False
Set ms = Worksheets("Houston-P")
On Error Resume Next
With Worksheets("Invoice Tracker")
LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
For i = 1 To LR
If .Cells(i, "B") = "HH" Then
If WorksheetFunction.CountIf(ms.Range("A:A"), .Cells(i, "A")) = 0 Then
a = Array(.Cells(i, "A").Value, .Cells(i, "B").Value, .Cells(i, "D").Value, .Cells(i, "F").Value, .Cells(i, "G").Value, .Cells(i, "H").Value, .Cells(i, "O").Value, .Cells(i, "P").Value)
ms.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Resize(, 8) = a
End If
End If
Next i
End With
Application.CutCopyMode = 0
Application.ScreenUpdating = True
Set ms = Nothing
End Sub
Please amend Code-Tags around the procedure in your post.
Ciao,
Holger
Bookmarks