Re : HELP URGENT => Problème d'affectation couleur "colorIndex" de mes lignes
Merci de ta réponse Robert, voici le nouveau fichier avec la macro corrigé.
Ce nouveau fichier vous permettra de comprendre les problèmes qui pour rappel sont les suivants:
Problème n°1=> mon index est à 38 ce qui est supérieur au code colorIndex.
Problème n°2=> j'ai découvert un bug dans mon code puisque dans le groupe index n°22 j'ai différente couleur!! cf. ligne 960 du fichier joint. donc ce n'est pas bon.
Merci bien.
Regarde la pièce jointe ClasseurTest.zip
le code vba est le suivant:
Sub MFC_Couleur()
Application.ScreenUpdating = False
Sheets("Données Maitre MOE").Visible = True
Sheets("Données Maitre MOE").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("G2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Set mondico = CreateObject("Scripting.Dictionary")
For Each Cel In Range("I2:i" & Range("I65536").End(xlUp).Row)
If Not mondico.Exists(Cel.Value) Then mondico.Add Cel.Value, Cel.Value
Next
For Each Item In mondico.items
If Item <> "" Then
couleur = 35 + Item
Else
Item = 0
couleur = 0
Exit Sub
End If
Set c = Columns("I").Find(Item, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
ld = c.Row: lf = ld - 1
Do
lf = lf + 1
Set c = Columns("i").FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
Range(Cells(ld, 1), Cells(lf, 9)).Interior.ColorIndex = couleur
End If
Range(Cells(ld, 1), Cells(lf, 9)).Interior.ColorIndex = couleur
lf = 0
Next
End Sub