• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete ALL Series Collection in XY scatter chart

nagovind

Member
Is it possible to delete ALL series in a chart using VBA code


I have recorded a macro but it is not doing the job ...as the series collection is not in series order some inbetween series collection does not exists so it is hard to find the exact number of the series collection to run the for loop to delete the existing series


Please help by providing a VBA code


thanks
 
Hi, nagovind!

What about posting your sample file with the recorded macro and detailed explanation of what's wrong?

Regards!
 
Activechart.SeriesCollection.count

Will return how many series there are which enables you to step through the series and work on them

[pre]
Code:
Sub Del_Series()
ActiveSheet.ChartObjects("Chart 1").Activate
For i = ActiveChart.SeriesCollection.Count To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
End Sub
[/pre]
 
or you can use the SeriesCollection object itself and loop through it

[pre]
Code:
Sub Del_Series()
ActiveSheet.ChartObjects("Chart 1").Activate
For Each Srs In ActiveChart.SeriesCollection
Srs.Delete
Next
End Sub
[/pre]
 
Thanks a lot

Working very fast ....

I'm away from the system hence the delay to acknowledge

thanks for the code !!!!!!!!
 
Back
Top