claire3131
XLDnaute Nouveau
Voila mon problème:
Sur ma feuille qui s'appelle ("calculs") il y a plusieurs graphique (Trois). Chacun est crée par une macro différente qui s'enclenche grâce à un bouton lui correspondant.
En fait, mon problème vient du fait que j'ai recherché sur internet un moyen d'effacer un graphique et j'ai trouvé cà :
Worksheets("Calculs").ChartObjects.Delete
Or cette ligne m'efface tous les graphiques de ma page alors que j'aimerais simplement effacer le graphique ancien pour le remplacer par le nouveau à l'activation du bouton qui lui correspond.
J'ai essayé:
Worksheets("Calculs").ChartObject("Graphique").Delete
Mais il me met l'erreur "Propriété ou méthode non non gérée par cette objet"
Je ne sais plus quoi faire
Merci pour vôtre aide
Je vous mets une des 3 macros
Dim nouveau_graphique As Chart
Worksheets("Calculs").ChartObjects.Delete
Range("C5:E18").Select
Set nouveau_graphique = Charts.Add
nouveau_graphique.Name = "Graphique"
nouveau_graphique.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Calculs").Range("C5:E18"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Calculs"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Productions mensuelles de pluies en litres"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Mois"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Productions (L)"
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlMedium
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlMedium
.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 = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveSheet.ChartObjects(1).Left = 400 'horizontal
ActiveSheet.ChartObjects(1).Top = 70 'vertical
ActiveWindow.Visible = False
Windows("Meteo.xls").Activate
Range("H20").Select
Sur ma feuille qui s'appelle ("calculs") il y a plusieurs graphique (Trois). Chacun est crée par une macro différente qui s'enclenche grâce à un bouton lui correspondant.
En fait, mon problème vient du fait que j'ai recherché sur internet un moyen d'effacer un graphique et j'ai trouvé cà :
Worksheets("Calculs").ChartObjects.Delete
Or cette ligne m'efface tous les graphiques de ma page alors que j'aimerais simplement effacer le graphique ancien pour le remplacer par le nouveau à l'activation du bouton qui lui correspond.
J'ai essayé:
Worksheets("Calculs").ChartObject("Graphique").Delete
Mais il me met l'erreur "Propriété ou méthode non non gérée par cette objet"
Je ne sais plus quoi faire
Merci pour vôtre aide
Je vous mets une des 3 macros
Dim nouveau_graphique As Chart
Worksheets("Calculs").ChartObjects.Delete
Range("C5:E18").Select
Set nouveau_graphique = Charts.Add
nouveau_graphique.Name = "Graphique"
nouveau_graphique.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Calculs").Range("C5:E18"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Calculs"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Productions mensuelles de pluies en litres"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Mois"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Productions (L)"
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlMedium
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlMedium
.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 = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveSheet.ChartObjects(1).Left = 400 'horizontal
ActiveSheet.ChartObjects(1).Top = 70 'vertical
ActiveWindow.Visible = False
Windows("Meteo.xls").Activate
Range("H20").Select