Sub Couleur(P As Range)
Dim col, fusion, ub%, i&, j%, x$, n&
col = Array(2, 6, 10, 12, 14, 16, 18)
fusion = Array(4, 3, 2, 2, 2, 2, 2)
ub = UBound(col)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
P.EntireRow.UnMerge 'défusionne
P.EntireRow.Sort P(1), xlAscending, P(1, 3), , xlAscending, Header:=xlNo 'tri sur 2 colonnes
For i = 1 To P.Rows.Count
For j = 0 To ub
P.EntireRow.Cells(i, col(j)).Resize(, fusion(j)).Merge 'refusionne
Next j
x = P(i, 1) & Chr(1) & P(i, 3)
If x <> P(i - 1, 1) & Chr(1) & P(i - 1, 3) And x = P(i + 1, 1) & Chr(1) & P(i + 1, 3) Then n = n + 1
If x = P(i + 1, 1) & Chr(1) & P(i + 1, 3) Or x = P(i - 1, 1) & Chr(1) & P(i - 1, 3) Then
Select Case n
Case 1: P.Rows(i).Font.ColorIndex = 3 'rouge
Case 2: P.Rows(i).Font.ColorIndex = 5 'bleu
Case 3: P.Rows(i).Font.ColorIndex = 46 'orange
Case 4: P.Rows(i).Font.ColorIndex = 14 'vert
Case 5: P.Rows(i).Font.ColorIndex = 53 'brun
End Select
Else
P.Rows(i).Font.Bold = False
P.Rows(i).Font.ColorIndex = xlAutomatic
End If
Next i
End Sub