Problem deleting series in a chart

K

keith

Hello,

I have a chart that has either one or two series’ in it, and I want to
delete all series’ in the chart so I can rebuild them. Using the following
code

ActiveChart.SeriesCollection.Delete

I receive the following error

Error 438 Object doesn't support this property or method


How can I delete all series’ without getting the error.

Thank you,

keith
 
J

Jacob Skaria

Dear Keith

Please try this and feedback.

For intTemp = 1 to ActiveChart.SeriesCollection.count
ActiveChart.SeriesCollection(intTemp).Delete
Next intTemp

If this post helps click Yes
 
K

keith

HI Jacob,
Thanks very much. I did not mention it in this latest message, but I tried
a for/next loop approach first and received occasional errors. I added an
error check by adding "on error resume next" before the delete statement, and
with that in place, I occasionally end up with a series that is not deleted.
I thought maybe the ActiveChart.SeriesCollection.Delete statement might
solve the problem. Am trying to see if there is another way to delete all
series' in the active chart without encountering errors.
Keith
 
J

Jon Peltier

No, you should either loop backwards:

For intTemp = ActiveChart.SeriesCollection.count to 1 step -1
ActiveChart.SeriesCollection(intTemp).Delete
Next intTemp

or keep deleting series 1 until there are no more series:

For intTemp = 1 to ActiveChart.SeriesCollection.count
ActiveChart.SeriesCollection(1).Delete
Next intTemp

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/>
Advanced Excel Conference - Training in Charting and Programming
http://peltiertech.com/Training/2009-06-ACNJ/AdvExcelConf200906ACNJ.html
_______
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top