You didn't mention how you want the result.
Sub test()
Dim a, i As Long, e, s, dic As Object, msg As String
Set dic = CreateObject("Scripting.Dictionary")
With CreateObject("Scripting.Dictionary")
For Each e In Array("Sheet2", "Sheet1")
a = Sheets(e).Range("b2").CurrentRegion.Value
For i = 2 To UBound(a, 1)
If e = "Sheet2" Then
If Not .exists(a(i, 1)) Then
Set .Item(a(i, 1)) = _
CreateObject("Scripting.Dictionary")
End If
.Item(a(i, 1))(a(i, 2)) = Empty
Else
If Not .exists(a(i, 1)) Then
If Not dic.exists(a(i, 1)) Then
Set dic(a(i, 1)) = _
CreateObject("Scripting.Dictionary")
End If
dic(a(i, 1))(a(i, 2)) = Empty
Else
If Not .Item(a(i, 1)).exists(a(i, 2)) Then
msg = msg & vbLf & a(i, 1) & " : " & a(i, 2)
End If
End If
End If
Next
Next
End With
If dic.Count <> 0 Then
For Each e In dic
For Each s In dic(e)
msg = msg & vbLf & e & " : " & s
Next
Next
End If
MsgBox msg, , "Missing index"
End Sub
Bookmarks