Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Deleting shape series and trendlines

I'm trying to delete all 20 series and trendlines of a shape. My code
doesn't delete them. What is going wrong?

ActiveSheet.ChartObjects("Shape 1").Activate

For i = 1 To 20
Err.Clear
ActiveChart.SeriesCollection(1).Delete
Err.Clear
Next i

Thanks,
Mika

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Deleting shape series and trendlines

Seems like it would be easier to cut the chart and start over but try this

Sub deleteseries()
ActiveSheet.ChartObjects("Chart 1").Activate
On Error Resume Next
For i = 20 To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Mika" wrote in message
...
I'm trying to delete all 20 series and trendlines of a shape. My code
doesn't delete them. What is going wrong?

ActiveSheet.ChartObjects("Shape 1").Activate

For i = 1 To 20
Err.Clear
ActiveChart.SeriesCollection(1).Delete
Err.Clear
Next i

Thanks,
Mika



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Deleting shape series and trendlines

Here's another if you only have ONE chart and you don't know how many series
to start with
Sub deleteseriescount()
ActiveSheet.ChartObjects(1).Activate
x = ActiveChart.SeriesCollection.Count
For i = x To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
Seems like it would be easier to cut the chart and start over but try this

Sub deleteseries()
ActiveSheet.ChartObjects("Chart 1").Activate
On Error Resume Next
For i = 20 To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Mika" wrote in message
...
I'm trying to delete all 20 series and trendlines of a shape. My code
doesn't delete them. What is going wrong?

ActiveSheet.ChartObjects("Shape 1").Activate

For i = 1 To 20
Err.Clear
ActiveChart.SeriesCollection(1).Delete
Err.Clear
Next i

Thanks,
Mika





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Deleting shape series and trendlines

If you don't know how many series, use this. Also, no need to activate
the chart.

Sub DeleteSeries()
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection
Do Until .Count = 0
.Item(1).Delete
Loop
End With
End Sub

If the chart is already active, use this:

Sub DeleteSeries()
With ActiveChart.SeriesCollection
Do Until .Count = 0
.Item(1).Delete
Loop
End With
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Don Guillett wrote:

Here's another if you only have ONE chart and you don't know how many series
to start with
Sub deleteseriescount()
ActiveSheet.ChartObjects(1).Activate
x = ActiveChart.SeriesCollection.Count
For i = x To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Deleting shape series and trendlines

It's great when you have THE charting expert around. Thanks Jon

--
Don Guillett
SalesAid Software

"Jon Peltier" wrote in message
...
If you don't know how many series, use this. Also, no need to activate
the chart.

Sub DeleteSeries()
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection
Do Until .Count = 0
.Item(1).Delete
Loop
End With
End Sub

If the chart is already active, use this:

Sub DeleteSeries()
With ActiveChart.SeriesCollection
Do Until .Count = 0
.Item(1).Delete
Loop
End With
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Don Guillett wrote:

Here's another if you only have ONE chart and you don't know how many

series
to start with
Sub deleteseriescount()
ActiveSheet.ChartObjects(1).Activate
x = ActiveChart.SeriesCollection.Count
For i = x To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
End Sub




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
XL2003: Shape-borders on scatter-series' look wavy Holger Gerths Charts and Charting in Excel 0 December 10th 08 12:22 PM
Format Shape, will not move accordingly, when deleting columns TJ Excel Discussion (Misc queries) 3 June 5th 08 07:13 PM
How do I change the shape of a data series juliejg1 Charts and Charting in Excel 2 July 12th 07 05:32 PM
Deleting a shape and the cell contents the shape is in. Dave Peterson[_3_] Excel Programming 1 October 9th 03 03:36 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM


All times are GMT +1. The time now is 09:04 AM.

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"