Hi,
I have added code to copy certain cells from a worksheet (Invoice Tracker) to a new worksheet (Houston-P) if a value in column B is equal to "HH". This is working but everything I run the macro, it copies cells it has copied before so my new worksheet contains a bunch of duplicates. How can I add to this code below so that it doesnt do that?
Thank you!
Sub Exporting_Data1()
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
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
Next i
End With
Application.CutCopyMode = 0
Application.ScreenUpdating = True
Set ms = Nothing
End Sub
Bookmarks