nb-
06-24-2009, 11:19 AM
I have a line chart with a number of series in it, some of which are have no data in them. They show up in the ledged, and are counted by .SeriesCollection.Count but for everything else they cause problems.
The problem is that these series seem to be empty/valueless, I have number of charts with a lot of these problem series in them, that I want to go through with VBA and delete. However .SeriesCollection(i).delete throws an error like the series is not there...
The following code is a simplified example to go with the simplified file attached. It throws an error on all the series I want to delete (red in the attached file), how can I delete these series using vba? :think:
Ideas / thoughts appreciated.
Option Explicit
Public Sub test()
Dim i As Integer
With ActiveChart
For i = .SeriesCollection.Count To 1 Step -1
Debug.Print i & " : " & .SeriesCollection(i).Name
.SeriesCollection(i).Delete
Next i
End With
End Sub
The problem is that these series seem to be empty/valueless, I have number of charts with a lot of these problem series in them, that I want to go through with VBA and delete. However .SeriesCollection(i).delete throws an error like the series is not there...
The following code is a simplified example to go with the simplified file attached. It throws an error on all the series I want to delete (red in the attached file), how can I delete these series using vba? :think:
Ideas / thoughts appreciated.
Option Explicit
Public Sub test()
Dim i As Integer
With ActiveChart
For i = .SeriesCollection.Count To 1 Step -1
Debug.Print i & " : " & .SeriesCollection(i).Name
.SeriesCollection(i).Delete
Next i
End With
End Sub