I have the below code to create a dictionary from the below attached file "Key & items Data Base.xlsx" where it will store data as shown below.
Option Explicit
Dim MyKeys As Dictionary
Private Sub crtdic()
Dim wbk As Workbook
Dim NewFile As Variant
Dim lrow As Long
NewFile = Application.GetOpenFilename("microsoft excel files (*.xls*), *.xlsm*")
If NewFile <> False Then
Set wbk = Workbooks.Open(NewFile)
End If
lrow = wbk.ActiveSheet.Cells(wbk.ActiveSheet.Rows.Count, "G").End(xlUp).Row
Dim Keys As Variant: Keys = wbk.ActiveSheet.Range("G2:H" & lrow).Value
Set MyKeys = New Dictionary
Dim i As Long
For i = 2 To UBound(Keys)
With MyKeys
If .Exists(Keys(i, 1)) Then
MyKeys(Keys(i, 1)) = MyKeys(Keys(i, 1)) & "," & Keys(i, 2)
Else
.Add Keys(i, 1), Keys(i, 2)
End If
End With
Next i
wbk.Close SaveChanges:=False
End Sub
What I want to achieve is
Using MyKeys dictionary I need to check in Lookup file1 to lookup file3 will be in a separate folder (attached in the above link) where Key will be there in column BS and its Item in column CI, to find is there any new Key or item are there which are not in the dictionary Mykeys.
If there are any new keys or items found then, need to create one new dictionary which will need to store site name (column A in the look up files) along with the keys and items like the below
In new sheet or file need to print report like the below. (Kindly refer the attached "Missing KEy & Items.xlsx" file)
Is this doable? if yes kindly guide me.
Using the Mykeys dictionary I just did a mockup test where I can get the exist or non exits item by using the following code. However I'm not getting anything :(
Sub pntdic()
Dim rng As Range, cell As Range
Dim c As Integer, c1 As Integer
Dim sht As Worksheet
Set sht = ActiveSheet
Set rng = Selection
Call crtdic
sht.Activate
For Each cell In rng
If MyKeys.Exists(cell.Value) Then
If MyKeys.Item(cell.Value) = cell.Value Then
cell.Offset(0, 2) = "Yes"
Else
cell.Offset(0, 2) = "no"
End If
End If
Next
End Sub



