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
|
Private Sub UserForm_Activate()
Dim i As Integer
Dim S1 As Object
Dim TabX(10), TabY(10)
Dim Cht As ChChart
Dim C As Object
'Remplissage des tableaux qui serviront à créer le graphique
For i = 0 To 9
TabX(i) = i
TabY(i) = Cells(4 + i, 3).Value
Next i
Set C = ChartSpace1.Constants
Set Cht = ChartSpace1.Charts.Add
With Cht
.Type = C.chChartTypeColumnClustered 'type de graphique:Barres
.HasLegend = True 'permet l'affichage des légendes
.Legend.Position = chLegendPositionBottom 'afichage des légendes sous le graphique
.HasTitle = True
.Title.Caption = "Graph1"
End With
Set S1 = Cht.SeriesCollection.Add
With S1
.Caption = "Nom de la série"
.Type = C.chChartTypeLine
.SetData C.chDimCategories, C.chDataLiteral, TabX
.SetData C.chDimValues, C.chDataLiteral, TabY
End With
End Sub |
Partager