Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping
Hello there,
Can anyone help me with a code that delets all series in a certain chart? No matter how many series there are. Thanks.... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping
Public Sub DeleteSeries()
Dim XLChart As Chart, XLSeriesCol As SeriesCollection, XLSeries As Series Set XLChart = Sheets("SheetName").ChartObjects(1).Chart ' above assumes your chart is the first or only one on the worksheet Set XLSeriesCol = XLChart.SeriesCollection For Each XLSeries In XLSeriesCol XLSeries.Delete Next XLSeries Set XLSeriesCol = Nothing Set XLChart = Nothing End Sub "Hannes" wrote: Hello there, Can anyone help me with a code that delets all series in a certain chart? No matter how many series there are. Thanks.... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping
Thans,
This is what I was looking for, but I cant get it to work. Set XLChart = Sheets("SheetName").ChartObjects(1).Chart I replaced the sheetname and chartobject number but It still comes up with an error. "K Dales" wrote: Public Sub DeleteSeries() Dim XLChart As Chart, XLSeriesCol As SeriesCollection, XLSeries As Series Set XLChart = Sheets("SheetName").ChartObjects(1).Chart ' above assumes your chart is the first or only one on the worksheet Set XLSeriesCol = XLChart.SeriesCollection For Each XLSeries In XLSeriesCol XLSeries.Delete Next XLSeries Set XLSeriesCol = Nothing Set XLChart = Nothing End Sub "Hannes" wrote: Hello there, Can anyone help me with a code that delets all series in a certain chart? No matter how many series there are. Thanks.... |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping
Would help to know the error message, but most likely it is because I wrote
the code assuming a regular worksheet with an embedded chart, you may well have a chart on its own sheet instead. A chart sheet is already a Chart object so you don't need to refer to the chartobjects on the sheet - in other words, the code would go like this: Set XLChart = Sheets("ChartSheetName") Then everything else should work, if my guess is correct. "Hannes" wrote: Thans, This is what I was looking for, but I cant get it to work. Set XLChart = Sheets("SheetName").ChartObjects(1).Chart I replaced the sheetname and chartobject number but It still comes up with an error. "K Dales" wrote: Public Sub DeleteSeries() Dim XLChart As Chart, XLSeriesCol As SeriesCollection, XLSeries As Series Set XLChart = Sheets("SheetName").ChartObjects(1).Chart ' above assumes your chart is the first or only one on the worksheet Set XLSeriesCol = XLChart.SeriesCollection For Each XLSeries In XLSeriesCol XLSeries.Delete Next XLSeries Set XLSeriesCol = Nothing Set XLChart = Nothing End Sub "Hannes" wrote: Hello there, Can anyone help me with a code that delets all series in a certain chart? No matter how many series there are. Thanks.... |