So I am trying to take a spreadsheet that is taken from another system - and update another spreadsheet if the Unique ID for each record is NOT already found in the new spreadsheets.
For example Record ABC1 is already on the Destination worksheets
Record XYZ2 is not
In the source data both of the above record exist. I want the macro to check to see if the ABC1 is on the destination worksheet, and if it is just update certain values. If not, copy the entire row and add it to the destination worksheet.
I can copy and paste all values...just trying to figure out the next one.[Sub AddNewOrUpdate()
'Defining Worksheets & Other
Dim Impsheet As Worksheet
Dim Destsheet As Worksheet
Dim Search As Variant
Dim IDs As Range
Dim dest_last_row As Integer
Set Impsheet = Sheets("SFEXport")
Set Destsheet = Sheets("Destination")
'Get the last row of the import worksheet
Import_last_row = Sheets("SFExport").Cells(Rows.Count, 1).End(xlUp).Row
'Get last row for destination sheet
dest_last_row = Destsheet.Cells(Rows.Count, 1).End(xlUp).Row
Set IDs = Destsheet.Range("A2:A" & dest_last_row)
'Output
For Each Cell In IDs
If Cell.Value = Search Then
Debug.Print "Found"
'Update the cells that might change
'DestSheet.Cells(MatchedRow, 4) = ImpSheet.Cells(ImpMatchedRow 4)
'DestSheet.Cells(MatchedRow, 5) = ImpSheet.Cells(ImpMatchedRow, 5)
'DestSheet.Cells(MatchedRow, 6) = ImpSheet.Cells(ImpMatchedRow, 6)
Delete Impsheet.Cells(FoundRow, 1).EntireRow.Delete
Exit Sub
Else
'Copy Data for new Worksheet
Impsheet.Cells(j, 1).EntireRow.Copy Destsheet.Cells(dest_last_row + 1, 1)
'Delete the Copied data
Impsheet.Cells(j, 1).EntireRow.Delete
End Sub]
Think I am following the logic now