Hello.
I have a host excel workbook which contains all the VBA Codes. When I click a button there, it must compare two workbook's data and generate a report file.
Workbook Data 1 contains this:
Workbook Data 2 contains this:
ID 1 must only be compared to ID 1 and so on thus generating a report file:
The Workbook Data 2 offsets and adjusts its placement in the row if they have NO MATCH.
Then ALIGNS to the Workbook Data 1 if the ROW of data are all the SAME with a REMARKS on the last column as MATCH.
I have tried making this code and this is as far as I have gone to:
In this code, I tried pasting the data of two workbooks to one workbook but I can't seem to know how to compare them from there.
Code
Sub copyData()
Dim Report0 As Variant
Dim sReport0 As String
sReport0 = ThisWorkbook.path & Application.PathSeparator & "\DATACOMPARE\Report.xlsx"
Set Report0 = Workbooks.Open(sReport0, ReadOnly:=False)
Dim Temp01 As Variant
Dim sTemp01 As String
sTemp01 = ThisWorkbook.path & Application.PathSeparator & "\DATACOMPARE\File1.xlsx"
Set Temp01 = Workbooks.Open(sTemp01, ReadOnly:=False)
Dim Temp02 As Variant
Dim sTemp02 As String
sTemp02 = ThisWorkbook.path & Application.PathSeparator & "\DATACOMPARE\File2.xlsx"
Set Temp02 = Workbooks.Open(sTemp02, ReadOnly:=False)
Application.ScreenUpdating = False
Workbooks("File1.xlsx").Worksheets(1).Range("B1:E200").Copy
Workbooks("Report.xlsx").Worksheets(1).Range("B1").PasteSpecial Paste:=xlPasteValues
Workbooks("File2.xlsx").Worksheets(1).Range("B1:E200").Copy
Workbooks("Report.xlsx").Worksheets(2).Range("B1").PasteSpecial Paste:=xlPasteValues
Application.DisplayAlerts = False
Workbooks("File1.xlsx").Close
Workbooks("File2.xlsx").Close
Application.ScreenUpdating = True
End Sub
Display More
Please help anyone. Thank you.