L
Legacy 330376
Guest
HI VBA Geeks,
Hope your well.
I have a question.
I have multiple source workbooks and I have a VBA code which moves data (based on a criteria) into the master spreadsheet. However I want to only move new rows of data into the masterworkbook, not duplicated rows.
Any ideas? Below is my code.
Hope your well.
I have a question.
I have multiple source workbooks and I have a VBA code which moves data (based on a criteria) into the master spreadsheet. However I want to only move new rows of data into the masterworkbook, not duplicated rows.
Any ideas? Below is my code.
Code:
Private Sub NC()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wb As Workbook, wsDATA As Worksheet, wasOPEN As Boolean
Dim i As Long, LastRow As Long
Set wsDATA = ActiveSheet
LastRow = wsDATA.Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
Set wb = Workbooks("Master Spreadsheet V3.xlsm")
On Error GoTo 0
If Not wb Is Nothing Then
wasOPEN = True
Else
Set wb = Workbooks.Open("C:\Master Spreadsheet V3.xlsm")
End If
With wsDATA
For i = 2 To LastRow
If .Cells(i, "A") = "NC" Then
If .Cells(i, "J") > 15 Or .Cells(i, "O") > 15 Then
.Range("A" & i).Resize(, 26).Copy
wb.Sheets("NC").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
End If
End If
Next i
If wasOPEN Then
wb.Save
Else
wb.Close True
End If
End With
Application.DisplayAlerts = False
On Error Resume Next
wb.ChangeFileAccess xlReadWrite
Application.Wait (Now + TimeValue("0:00:08"))
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub