Erreur 1004 à la ligne ActiveChart.SeriesCollection(2)

Bonjour

J'ai une macro qui génère un graphique avec 2 lignes brisées :

Sub CrGraphLectMoy()

    Range("C53:G53").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData Source:=Range("NotesGraphEnCours!$C$53:$G$53") ' la ligne bleue
    ActiveChart.SetElement (msoElementChartTitleAboveChart)
    Selection.Caption = "=NotesGraphEnCours!R5C1"
    ActiveChart.Legend.Select
    ActiveChart.Legend.LegendEntries(1).Select
    ActiveChart.ChartArea.Select
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    ActiveChart.SeriesCollection(1).Name = "=NotesGraphEnCours!$B$53" 'Nom : Moyenne
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(2).Name = "=NotesGraphEnCours!$B$129" 'Nom de ma moyenne de la dernière étape
    ActiveChart.SeriesCollection(2).Values = "=NotesGraphEnCours!$C$129:$G$129" 'moyennes dern etape
    ActiveChart.SeriesCollection(2).XValues = "=NotesGraphEnCours!$C$11:$G$11"  'Moyenne des évaluations
    ActiveChart.ChartArea.Select
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).MinimumScale = 0
    ActiveChart.Axes(xlValue).MinimumScale = 50
    ActiveChart.Axes(xlValue).MaximumScale = 100
    ActiveChart.Axes(xlValue).MajorUnit = 5
    ActiveChart.Axes(xlValue).MajorUnit = 10
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).ApplyDataLabels
    ActiveChart.SeriesCollection(1).DataLabels.Select
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).DataLabels.Select
    Selection.NumberFormat = "# ##0.00"
    Selection.NumberFormat = "0.0"
    ActiveChart.Axes(xlCategory).Select
    Selection.TickLabels.Orientation = 60
End Sub

Bon, je ne suis pas fou, il y a bel et bien une ActiveChart.SeriesCollection (2)... Ensuite, j'ai un menu rotatif qui me permettrait de changer les donnée du graphique en question... Quand il lit le code, il change les valeurs de ma ligne bleue (ActiveChart.SeriesCollection(1)) mais lorsqu'il arrive à ActiveChartSeriesCollection(2), il plante, comme si il ne trouvait pas la 2e collection?

Voici la macro associée au menu déroulant :

Sub ActuGraphMoy()
Dim DerColonne As Integer
Dim MenuRotatif As Integer

DerColonne = Range("C6").End(xlToRight).Column
MenuRotatif = Range("E1").Value

If MenuRotatif = 1 Then
    ActiveSheet.ChartObjects("Graphique 2").Activate
    ActiveChart.SetSourceData Source:=Range(Cells(53, 3), Cells(53, DerColonne))
    ActiveChart.SeriesCollection(1).Name = Range("B12") ' Nom de la ligne bleue
    ActiveChart.SeriesCollection(1).XValues = Range(Cells(11, 3), Cells(11, DerColonne)) ' Notes de la moyenne des diff tests
    ActiveChart.SeriesCollection(2).XValues = Range(Cells(129, 3), Cells(129, DerColonne)) ' Ligne rouge, la moy à la derniere étape

Else
    ActiveSheet.ChartObjects("Graphique 2").Activate
    ActiveChart.SetSourceData Source:=Range(Cells(11 + MenuRotatif, 3), Cells(11 + MenuRotatif, DerColonne))
    ActiveChart.SeriesCollection(1).XValues = Range(Cells(11 + MenuRotatif, 3), Cells(11 + MenuRotatif, DerColonne)) ' Notes des notes de cet élève aux diff tests
    ActiveChart.SeriesCollection(2).XValues = Range(Cells(76 + MenuRotatif, 3), Cells(76 + MenuRotatif, DerColonne))
End If

End Sub

Je dois avouer que je ne comprends pas trop la différence entre Xvalue ou Value, mais même en les changeant, ça plante toujours à la ligne de seriescollection(2).

Mon fichier est là aussi...

Merci

Rechercher des sujets similaires à "erreur 1004 ligne activechart seriescollection"