Sub Update_XYZ_File()
Set XYZ_file = ThisWorkbook
Set ABC_file = Workbooks.Open("C:\Users\ASUS\Downloads\ABC.xlsm") 'provide file path of your required file
Set XYZfile_sheet = XYZ_file.Sheets("Purchase") ' provide the sheet name from your file
Set ABCfile_sheet = ABC_file.Sheets("Sheet2") ' provide the sheet name from your file
Dim ABClast_row As Integer
ABClast_row = ABCfile_sheet.Cells(Rows.Count, 2).End(xlUp).Row
Set ABCsheet_range = ABCfile_sheet.Range("A3:C" & ABClast_row)
Dim i As Integer
Dim j As Integer
Dim data_match As Boolean
Dim XYZlast_row As Integer
Dim ABC_data As String
Dim XYZ_data As String
Dim last_row As Integer
Application.DisplayAlerts = False
Set missing_data = Nothing
For i = 1 To ABCsheet_range.Rows.Count
data_match = False
XYZlast_row = XYZfile_sheet.Cells(Rows.Count, 2).End(xlUp).Row
Set XYZsheet_range = XYZfile_sheet.Range("A3:C" & XYZlast_row)
ABC_data = ""
ABC_data = JoinRow(ABCsheet_range.Rows(i))
For j = 1 To XYZsheet_range.Rows.Count
XYZ_data = ""
XYZ_data = JoinRow(XYZsheet_range.Rows(j))
If ABC_data = XYZ_data Then
data_match = True
Exit For
End If
Next j
If data_match = False Then
If missing_data Is Nothing Then
Set missing_data = ABCsheet_range.Rows(i)
Else
Set missing_data = Union(missing_data, ABCsheet_range.Rows(i))
End If
End If
Next i
missing_data.Copy
XYZfile_sheet.Cells(XYZlast_row + 1, 1).PasteSpecial Paste:=xlPasteAll
Application.CutCopyMode = False
Application.DisplayAlerts = True
ABC_file.Close SaveChanges:=False
End Sub
Function JoinRow(row_range As Range) As String
Dim cell As Range
Dim result As String
For Each cell In row_range.Cells
result = result & "," & cell.Value
Next cell
JoinRow = result
End Function