Hello,
I have a host excel workbook which contains all the VBA Codes. When I click a "Submit" button there, it must compare the ID Number in two workbooks. After finding and matching all the ID Number, create another workbook and generate all the ID Number who successfully finding their match.
Workbook Data 1 contains this:
Workbook Data 2 contains this:
I have tried making this code and this is far as I have gone to:
In this code, I tried pasting the data of one workbook to new workbook, but I can't seem to know how to find and match all the ID Number from both workbooks then paste it into new workbook.
Code
Sub Sample()
Dim wbI As Workbook, wbO As Workbook
Dim wsI As Worksheet, wsO As Worksheet
'~~> Source/Input Workbook
Set wbI = ThisWorkbook
'~~> Set the relevant sheet from where you want to copy
Set wsI = wbI.Sheets("Sheet1")
'~~> Destination/Output Workbook
Set wbO = Workbooks.Add
With wbO
'~~> Set the relevant sheet to where you want to paste
Set wsO = wbO.Sheets("Sheet1")
'~~>. Save the file
.SaveAs Filename:="C:\Book2.xls", FileFormat:=56
'~~> Copy the range
wsI.Range("A1:B10").Copy
'~~> Paste it in say Cell A1. Change as applicable
wsO.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
End Sub
Display More
Please help anyone. Thank you.