Bonjour, voici le code que j'utilise:
Le problème est qu'il crée bien le graphique, mais pas la mise en forme!
Code:
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Feuil2").Range(ch), PlotBy:=xlRows
ActiveChart.SeriesCollection(1).Name = "=Feuil2!R3C1"
ActiveChart.SeriesCollection(2).Name = "=Feuil2!R4C1"
ActiveChart.SeriesCollection(3).Name = "=Feuil2!R5C1"
ActiveChart.SeriesCollection(4).Name = "=Feuil2!R6C1"
ActiveChart.SeriesCollection(5).Name = "=Feuil2!R7C1"
ActiveChart.SeriesCollection(6).Name = "=Feuil2!R8C1"
ActiveChart.SeriesCollection(7).Name = "=Feuil2!R9C1"
ActiveChart.SeriesCollection(8).Name = "=Feuil2!R10C1"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil2"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
ActiveSheet.ChartObjects(1).Activate
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.BaseUnitIsAuto = True
.MajorUnitIsAuto = True
.MinorUnitIsAuto = True
.Crosses = xlAutomatic
.AxisBetweenCategories = True
.ReversePlotOrder = False
End With
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.BaseUnit = xlMonths
.MajorUnit = 1
.MajorUnitScale = xlMonths
.MinorUnit = 1
.MinorUnitScale = xlMonths
.Crosses = xlAutomatic
.AxisBetweenCategories = True
.ReversePlotOrder = False
End With
With ActiveSheet.ChartObjects(1)
.Left = Range("A1").Left
.Top = Range("A1").Top
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 8
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=1, _
Degree:=0.331364919508659
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 8
End With
ActiveChart.Axes(xlValue).Select
ActiveChart.ChartArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = _
"Répartition du nombre d'appels par centre de gestion"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Mois"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Nbre d'appels"
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
Le problème est qu'il crée bien le graphique, mais pas la mise en forme!