Public Sub Trung()
Dim Vung, Gom, Tach, Ten, I, d, K
Set d = CreateObject("scripting.dictionary")
Set Ten = Range([C4], [A4].End(xlToRight)): K = 2
Set Vung = Range([B5], [B10000].End(xlUp)).Resize(, Range([B4], [A4].End(xlToRight)).Columns.Count)
Ten.Interior.ColorIndex = xlNone
For I = 1 To Vung.Columns.Count
Gom = Join(Application.WorksheetFunction.Transpose(Vung.Resize(, 1).Offset(, I)))
If Not d.exists(Gom) Then
K = K + 1
d.Add Gom, K & " " & I
Else
Tach = Split(d.Item(Gom))
Ten(Val(Tach(1))).Interior.ColorIndex = Val(Tach(0))
Ten(I).Interior.ColorIndex = Val(Tach(0))
MsgBox "Hai em trung nhau là: " & Ten(Val(Tach(1))) & " & " & Ten(I)
End If
Next I
End Sub