Move New Rows Of Data into Destination Workbook

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.

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
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top