Question : Excel:  Looping through all chart series of all charts on a worksheet

I need to be able to loop through all my charts (without selecting them) and modify the chart series value.  I can't seem to get at the value or xvalues property of the series.  What am I doing wrong?

Thanks experts!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Private Sub reset_chartseries()    
    Dim c As ChartObject
    Dim n As Integer
    Dim cs As SeriesCollection

    For Each c In rws.ChartObjects
        Set c = rws.ChartObjects(c.Name)
            For n = c.Chart.SeriesCollection.Count To 1 Step -1
                Set cs = c.Chart.SeriesCollection
                    Debug.Print cs(n).Values

'here is where I will do an if statement
' if value = "[0]" then xvalue ="reports!named range"

            Next
    Next
End Sub

Answer : Excel:  Looping through all chart series of all charts on a worksheet

Values returns an array not an object.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Private Sub reset_chartseries()    
    Dim c As ChartObject
    Dim n As Integer
    Dim cs As SeriesCollection
    Dim varData

    For Each c In rws.ChartObjects
        For each cs in c.Chart.SeriesCollection
           varData = cs.Values
           For n = lbound(vardata) to ubound(vardata)
              if varData(n) = 0 then
                 ' do whatever
              End if
           Next n
         next cs
    Next c
End Sub
Random Solutions  
 
programming4us programming4us