#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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....

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping scottwilsonx[_52_] Excel Programming 1 October 5th 04 04:13 PM
Looping [email protected] Excel Programming 0 October 31st 03 07:47 PM
Looping Stuart[_9_] Excel Programming 0 October 29th 03 11:31 PM
Looping J.E. McGimpsey Excel Programming 0 October 29th 03 11:09 PM
Need Looping Help [email protected] Excel Programming 2 October 29th 03 08:11 PM


All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"