Option Explicit
Sub TEST6()
Dim ar, i&, j&, r&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Worksheets(2).[A1].CurrentRegion.Value
For i = 2 To UBound(ar)
dic(ar(i, 1)) = ar(i, 5)
Next i
r = Cells(Rows.Count, "A").End(xlUp).Row
ar = Range("A1:H" & r).Value
For i = 2 To UBound(ar)
If dic.exists(ar(i, 2)) Then
For j = 6 To 8
If ar(i, 8) Then
If Mid(ar(1, j), 1, 1) <> dic(ar(i, 2)) Then ar(i, j) = Empty
End If
Next j
End If
Next i
[A1].Resize(UBound(ar), UBound(ar, 2)) = ar
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|