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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Dim graph As Chart
Dim statut(1 To 8) As Long
Dim lib(1 To 8) As Long
Dim i As Long
Dim Table As Range
Set graph = ActiveChart
Set Table = Range("Statuts_article").ListObject.ListColumns("Statut Article").DataBodyRange
lib(1) = graph.SeriesCollection(1).Points(1).DataLabel
lib(2) = graph.FullSeriesCollection(1).Points(2).DataLabel.Text
lib(3) = graph.FullSeriesCollection(1).Points(3).DataLabel.Text
lib(4) = graph.FullSeriesCollection(1).Points(4).DataLabel.Text
lib(5) = graph.FullSeriesCollection(1).Points(5).DataLabel.Text
lib(6) = graph.FullSeriesCollection(1).Points(6).DataLabel.Text
lib(7) = graph.FullSeriesCollection(1).Points(7).DataLabel.Text
lib(8) = graph.FullSeriesCollection(1).Points(8).DataLabel.Text
statut(1) = Table.Cells(Application.Match(lib(1), Table, 0), 1).Interior.Color
statut(2) = Table.Cells(Application.Match(lib(2), Table, 0), 1).Interior.Color
statut(3) = Table.Cells(Application.Match(lib(3), Table, 0), 1).Interior.Color
statut(4) = Table.Cells(Application.Match(lib(4), Table, 0), 1).Interior.Color
statut(5) = Table.Cells(Application.Match(lib(5), Table, 0), 1).Interior.Color
statut(6) = Table.Cells(Application.Match(lib(6), Table, 0), 1).Interior.Color
statut(7) = Table.Cells(Application.Match(lib(7), Table, 0), 1).Interior.Color
statut(8) = Table.Cells(Application.Match(lib(8), Table, 0), 1).Interior.Color
On Error Resume Next
If graph Is Nothing Then
MsgBox "Vous devez d'abord sélectionner un graphique."
Exit Sub
End If
For i = 1 To 8
With graph.FullSeriesCollection(1).Points(i).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = statut(i)
.Transparency = 0
.Solid
End With
With graph.FullSeriesCollection(1).Points(i).Format.Line
.Visible = msoFalse
End With
Next |
Partager