Erreur d'execution '1004'

leoriviera25

XLDnaute Nouveau
Bonjour,

J'ai construit un tableau automatique, et j'ai cette erreur suivante:
Erreur d'execution '1004'
Impossible de lire la propriété ChartObjects de la classe Worksheet

voici le code:

Option Explicit

Private Sub CommandButton1_Click()
Dim X As Byte, i As Byte
Dim j As Integer, Debut As Integer, Fin As Integer
Dim Plage As Range, Plage2 As Range

If ListBox1.Value = "" Then Exit Sub
If ComboBox1.ListIndex = -1 Or ComboBox2.ListIndex = -1 Then Exit Sub

If ComboBox1.ListIndex > ComboBox2.ListIndex Then
MsgBox "La date de fin ne peut pas etre antérieure à la date de début ."
Exit Sub
End If

Debut = ComboBox1.ListIndex + 2
Fin = ComboBox2.ListIndex + 2

Set Plage = Feuil1.Range("A" & Debut & ":A" & Fin)

Application.ScreenUpdating = False
Worksheets(1).ChartObjects("Graphique 1").Activate

For j = ActiveChart.SeriesCollection.Count To 1 Step -1
ActiveChart.SeriesCollection(j).Delete
Next j

For i = 0 To ListBox1.ListCount - 1 'boucle sur les éléments de la listbox

If ListBox1.Selected(i) = True Then
X = X + 1

ActiveChart.SeriesCollection.NewSeries
Set Plage2 = Feuil1.Range(Feuil1.Cells(Debut, i + 2).Address & ":" & Feuil1.Cells(Fin, i + 2).Address)

ActiveChart.SeriesCollection(X).Values = Plage2
If X = 1 Then ActiveChart.SeriesCollection(X).XValues = Plage
ActiveChart.SeriesCollection(X).Name = ListBox1.List(i) ' nom de la courbe
ActiveChart.SeriesCollection(X).Border.ColorIndex = i + 4
End If

Next i

Unload Me
Feuil1.Range("K373").Select
Application.ScreenUpdating = True

End Sub

Private Sub UserForm_Initialize()
Dim X As Byte
Dim Y As Integer

For X = 2 To 19
ListBox1.AddItem Feuil1.Cells(1, X)
Next X

For Y = 2 To 13
ComboBox1.AddItem Format(Feuil1.Range("A" & Y), "dd mmmm")
ComboBox2.AddItem Format(Feuil1.Range("A" & Y), "dd mmmm")
Next Y

End Sub





Merci
 

Discussions similaires

Réponses
11
Affichages
378
Réponses
17
Affichages
968

Statistiques des forums

Discussions
312 748
Messages
2 091 618
Membres
105 009
dernier inscrit
aurelien76110