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
| Sub Test()
Dim Grf As ChartObject
Dim Sh As Worksheet
Dim i As Integer
Dim p As Point
i = 1
i = i + 1
Set Sh = Sheets("Données")
'EDIT On supprime le graphique nommé Toto de la feuille Données
For Each Grf In Sh.ChartObjects
If Grf.Name = "Toto" Then
Grf.Delete
Exit For
End If
Next Grf
For Each p In ActiveChart.SeriesCollection(1).Points
If Range("C2:C14") = "1" Then
ActiveChart.SeriesCollection(1).Points(i).Interior.ColorIndex = 32
Else
ActiveChart.SeriesCollection(1).Points(i).Interior.ColorIndex = 3
End If
Next p
'On crée notre graphique
Set Grf = Sh.ChartObjects.Add(300, 50, 500, 300)
Grf.Name = "Toto"
With Grf.Chart
.ChartType = xlLineMarkers
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Values = Sh.Range("B2:B14")
End With
End With
Set Grf = Nothing
Set Sh = Nothing
End Sub |
Partager