shba,
Updated code, should address both issues:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Dn As Range, rngFound As Range
Dim K
Dim col
Dim c As Integer
Dim varFind As Variant
For Each varFind In Array("IP", "ID", "NAME")
Set rngFound = Target.Parent.Rows(1).Find(varFind, , xlValues, xlWhole)
If Not rngFound Is Nothing Then
If Target.Column = rngFound.Column Then
Set Rng = Range(Cells(1, Target.Column), Cells(Rows.Count, Target.Column).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value) Then
.Add Dn.Value, Dn
Else
Set .Item(Dn.Value) = Union(.Item(Dn.Value), Dn)
End If
Next
col = Array(3, 50, 6, 7, 8, 34, 35, 38, 39, 50, 45, 46)
For Each K In .keys
If .Item(K).Count > 1 Then
c = IIf(c = 12, 0, c)
.Item(K).Interior.ColorIndex = col(c)
c = c + 1
End If
Next K
End With
End If
End If
Next varFind
End Sub
Bookmarks