Hi the code below is a rule which highlights duplicates in different colors, can anyone help me with the Set Rng bit, I need it to simply work on the entire document not just column A.
Also the code in italics cannot be changed I need it to work on the entire document AS LONG AS it is on columns I choose.
Thank you
Also the code in italics cannot be changed I need it to work on the entire document AS LONG AS it is on columns I choose.
Code:
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
Set rngFound = Target.Parent.Rows(1).Find("IP", , xlValues, xlWhole)
If rngFound Is Nothing Then Exit Sub
If Target.Column = rngFound.Column Then
Set Rng = Range(Range("A1"), Range("A" & Rows.Count).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 Sub