1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
Sub GroupColor2CritèresColAColB()
Application.ScreenUpdating = False
Set f = Sheets("feuil1")
couleurs = Array(1, 3, 4, 6, 7, 8, 14, 15, 17, 20, 22, 24, 26, 27, 28, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 50, 53)
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In f.Range("a2", f.[a65000].End(xlUp))
clé = c.Value & "|" & sansTiret(c.Offset(, 1))
mondico.Item(clé) = mondico.Item(clé) + 1
Next c
For Each c In f.Range("a2", f.[a65000].End(xlUp))
clé = c.Value & "|" & sansTiret(c.Offset(, 1))
If mondico.Item(clé) > 1 Then
nocoul = (Application.Match(clé, mondico.keys, 0)) Mod UBound(couleurs)
c.Resize(, 2).Interior.ColorIndex = couleurs(nocoul)
End If
Next c
'-------------------liste sans doublons
f.[i2].Resize(mondico.Count) = Application.Transpose(mondico.keys)
f.[i2].Resize(mondico.Count).TextToColumns Other:=True, OtherChar:="|"
End Sub
Function sansTiret(c)
sansTiret = Application.Trim(Replace(c, "-", " "))
End Function |
Partager