Sub Macro_tri_auto()
Dim i&, j&, c()
With ActiveWorkbook.Worksheets("Feuil1").Range("D2:F2")
ReDim c(1 To .Cells.Count, 1)
For i = 1 To .Cells.Count
With .Cells(i)
c(i, 0) = .Value
j = .Interior.Color
c(i, 1) = Array(j Mod 256, (j \ 256) Mod 256, j \ 65536)
End With
Next
With .Parent.Sort
.SortFields.Clear
.SortFields.Add Key:=.Parent.Range("C7:F7"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
.SetRange .Parent.Range("C2:F7")
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
.Parent.ChartObjects("Graphique 1").Activate
For i = 1 To .Cells.Count: For j = 1 To .Cells.Count
If .Cells(i).Value = c(j, 0) Then
.Cells(i).Interior.Color = RGB(c(j, 1)(0), c(j, 1)(1), c(j, 1)(2))
ActiveChart.SeriesCollection(1).Points(i).Format.Fill.ForeColor.RGB = RGB(c(j, 1)(0), c(j, 1)(1), c(j, 1)(2))
Exit For
End If
Next j, i
End With
Range("H8").Select
End Sub