https://postimg.org/image/laeyoj9wn/ = List
https://postimg.org/image/ihlr4i9k7/ = Master list
I would like to compare the List and Master list serial number. If there is similarity value in serial number the serial number value will be automatically paste on the third column
Sub AutoUpdate()
Dim Dic As Object, key As Variant, oCell As Range, i&
Dim w1 As Worksheet, w2 As Worksheet
Set Dic = CreateObject("Scripting.Dictionary")
Set w1 = Workbooks("Book1.xlsm").Sheets("Sheet1")
Set w2 = Workbooks.Open("C:\UsersSurvey Testing\Book2.xlsx").Sheets("Sheet1")
Set w3 = Workbooks.Open("C:\Users\Survey Testing\Book3.xlsx").Sheets("Sheet1")
i = w2.Cells.SpecialCells(xlCellTypeLastCell).Row
For Each oCell In w2.Range("A2:A" & i)
If Not Dic.exists(oCell.Value) Then
Dic.Add oCell.Value, oCell.Offset(, 0).Value
End If
Next
i = w3.Cells.SpecialCells(xlCellTypeLastCell).Row
For Each oCell In w3.Range("A2:A" & i)
If Not Dic.exists(oCell.Value) Then
Dic.Add oCell.Value, oCell.Offset(, 0).Value
End If
Next
i = w1.Cells.SpecialCells(xlCellTypeLastCell).Row
For Each oCell In w1.Range("A2:A" & i)
For Each key In Dic
If oCell.Value = key Then
oCell.Offset(, 2).Value = Dic(key)
End If
Next
Next
End Sub
Instead of setting the workbook 1 by 1 in the code, I would like to automatically find and set all the workbook in the folder and compare. Because there might be alot of workbook that need to be compare.