Stumped... Looping through chart series collections..

Sthrncali

Board Regular
Joined
Apr 1, 2011
Messages
226
So... This code was working fine, but now it's not... I am a little stumped.. It works A-OK if there is only 1 chart visible on the worksheet, however if I have 2 charts visible the code stops removing the desired series collection..

Code:
Dim SeriesNum As Integer, CurrSeries As String, i As Integer, cht As Integer, myChart As Chart, SeriesColl As Series
Dim chr As Integer, find As Integer, Row As Integer
On Error Resume Next


 
For cht = 1 To Sheet3.ChartObjects.Count
    If Sheet3.ChartObjects(cht).Visible = True Then
    
    Sheet3.ChartObjects(cht).Activate
    
        For Each SeriesColl In ActiveChart.SeriesCollection
            If SeriesColl.Name = CurrSeries Then
            SeriesColl.Delete
            End If
            Debug.Print CurrSeries
            Debug.Print SeriesColl.Name
        Next SeriesColl
    
    End If
Next cht

Immediate Window:
All Sites All Departments  (Feb-2014)
All Sites All Departments (Feb-2014)
labelTracker Chart_Kicker Health 1
All Sites All Departments  (Feb-2014)
All Sites All Departments (Jan-2014)
labelTracker Chart_Kicker Health 1
All Sites All Departments  (Feb-2014)
All Sites All Departments (Feb-2014)
labelTracker Chart_Kicker Health 2
All Sites All Departments  (Feb-2014)
All Sites All Departments (Jan-2014)
labelTracker Chart_Kicker Health 2
'End Immediate Window Output

Couple strange items to note...
Sheet3 name is not "labelTracker"
the worksheet named "labelTracker" has no charts.
There are 2 charts visible on sheet 3 when code runs, called "Chart_Kicker Health 1" and "Chart_Kicker Health 2". Both charts have 2 data series which were loaded via VBA, however based on the immediate window output it looks like each series is counting twice...

Anyone have any ideas what's going on here? I rebooted my pc several times thinking there might be a mem leak or something like that occuring but the issue persists..
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Ya im stupid... See the error now in the Immediate output, there is an extra space in the varString im searching for..

#sillymistakes
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top