Rechercher : dans
Par :

Problème de series ds le graphique vba excel

seyive2004, le 30 mar 2009 à 11:31:25 
 Signaler ce message aux modérateurs

Bonjour à tous,
voilà j'ai un gros problème que j'ai du mal à resoudre,
en fait j'ai ecrit un programme sur vba excel, qui permet de tracé un graphe à partir des valeurs d'un tableau, le problème c'est que dans la légende j'ai des series en trop!j'ai mes series qui sont nommées et en plus j'ai des serie7, serie8,...qui apparaissent alors qu'ils n'existent pas et je n'arrive pas à m'en débarasser!
voici un de mes programme de graphe que j'ai ecrit:

Sub graphIMSCEVCSCMensueletGlissant()
'


Dim f As Integer
Dim e As Integer
Dim d As Integer
Dim max As Integer
Dim i As Integer
myroutine:
f = Application.InputBox("entrez le nombre de mois à afficher sur le graphe:")
max = 29
e = max - f
d = 6
Charts.Add
ActiveChart.ChartType = xlLine
For i = 1 To 6
ActiveChart.SeriesCollection.NewSeries
If d <= 11 And e >= 2 Then
ActiveChart.SeriesCollection(i).Values = Worksheets("IMSCEV_EXCE_CSC").Range(Worksheets("IMSCEV_EXCE_CSC").Cells(d, e), Worksheets("IMSCEV_EXCE_CSC").Cells(d, max))
d = d + 1
Else:
MsgBox "le nombre de mois choisi est superieur au nombre de mois existant"
GoSub myroutine
Exit Sub
End If
ActiveChart.SeriesCollection(1).XValues = Worksheets("IMSCEV_EXCE_CSC").Range(Worksheets("IMSCEV_EXCE_CSC").Cells(5, e), Worksheets("IMSCEV_EXCE_CSC").Cells(5, max))
Next i
ActiveChart.SeriesCollection(1).Name = "=""CSC Caen"""
ActiveChart.SeriesCollection(2).Name = "=""CSC Marseille"""
ActiveChart.SeriesCollection(3).Name = "=""CSC Paris"""
ActiveChart.SeriesCollection(4).Name = "=""CSC Strasbourg"""
ActiveChart.SeriesCollection(5).Name = "=""IMSC_EV_PABX global"""
ActiveChart.SeriesCollection(6).Name = "=""Objectif"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="IMSCEV_EXCE_CSC"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Excellence Enquête Evenementielle PABX(mensuel)"
End With
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(1).Select
ActiveChart.Legend.LegendEntries(1).LegendKey.Select
With Selection.Border
.ColorIndex = 11
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(2).LegendKey.Select
'ActiveChart.Legend.LegendEntries(2).LegendKey.Select
With Selection.Border
.ColorIndex = 13
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(3).LegendKey.Select
With Selection.Border
.ColorIndex = 7
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(4).LegendKey.Select
With Selection.Border
.ColorIndex = 54
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(5).LegendKey.Select
With Selection.Border
.ColorIndex = 8
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(6).LegendKey.Select
With Selection.Border
.ColorIndex = 3
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 34
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 0.1
.MaximumScale = 0.5
.MinorUnit = 0.01
.MajorUnit = 0.05
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Legend.Select
Selection.Position = xlBottom




max = 59
e = max - f
d = 6
Charts.Add
ActiveChart.ChartType = xlLine
For i = 1 To 6
ActiveChart.SeriesCollection.NewSeries
If d <= 11 And e >= 2 Then
ActiveChart.SeriesCollection(i).Values = Worksheets("IMSCEV_EXCE_CSC").Range(Worksheets("IMSCEV_EXCE_CSC").Cells(d, e), Worksheets("IMSCEV_EXCE_CSC").Cells(d, max))
d = d + 1
'Else:
' MsgBox "le nombre de mois choisi est superieur au nombre de mois existant"
' GoSub myroutine
'Exit Sub
End If
ActiveChart.SeriesCollection(1).XValues = Worksheets("IMSCEV_EXCE_CSC").Range(Worksheets("IMSCEV_EXCE_CSC").Cells(5, e), Worksheets("IMSCEV_EXCE_CSC").Cells(5, max))
Next i
ActiveChart.SeriesCollection(1).Name = "=""CSC Caen"""
ActiveChart.SeriesCollection(2).Name = "=""CSC Marseille"""
ActiveChart.SeriesCollection(3).Name = "=""CSC Paris"""
ActiveChart.SeriesCollection(4).Name = "=""CSC Strasbourg"""
ActiveChart.SeriesCollection(5).Name = "=""IMSC_EV_PABX global"""
ActiveChart.SeriesCollection(6).Name = "=""Objectif"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="IMSCEV_EXCE_CSC"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Excellence Enquête Evenementielle PABX(sem glissant)"
End With
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(1).Select
ActiveChart.Legend.LegendEntries(1).LegendKey.Select
With Selection.Border
.ColorIndex = 11
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(2).LegendKey.Select
'ActiveChart.Legend.LegendEntries(3).LegendKey.Select
With Selection.Border
.ColorIndex = 13
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(3).LegendKey.Select
With Selection.Border
.ColorIndex = 7
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(4).LegendKey.Select
With Selection.Border
.ColorIndex = 54
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(5).LegendKey.Select
With Selection.Border
.ColorIndex = 8
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Legend.LegendEntries(6).LegendKey.Select
With Selection.Border
.ColorIndex = 3
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 34
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 0.1
.MaximumScale = 0.5
.MinorUnit = 0.01
.MajorUnit = 0.05
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Legend.Select
Selection.Position = xlBottom





End Sub

Configuration: Windows XP
Internet Explorer 6.0