Chart.SeriesCollection method (Project)
Returns an object that represents either one series (a Series object) or a collection of the series (a SeriesCollection object) in the chart or chart group.
Syntax
expression.SeriesCollection (Index)
expression A variable that represents a Chart object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Index | Optional | Variant | The name or index number of the series. If Index is not specified, the SeriesCollection method returns all of the series in the chart. |
Index | Optional | Variant |
Return value
Object
Example
To get a single series, specify the Index parameter. The following example prints the first value of the "Actual Work" series. The first call to the SeriesCollection method gets the collection of all the series in the chart. The second call to the SeriesCollection method gets one specific series.
Sub GetSeriesValue()
Dim reportName As String
Dim theReportIndex As Integer
Dim theChart As Chart
Dim seriesInChart As SeriesCollection
Dim chartSeries As Series
reportName = "Simple scalar chart"
If (ActiveProject.Reports.IsPresent(reportName)) Then
' Make the report active.
theReportIndex = ActiveProject.Reports(reportName).Index
ActiveProject.Reports(theReportIndex).Apply
Set theChart = ActiveProject.Reports(theReportIndex).Shapes(1).Chart
Set seriesInChart = theChart.SeriesCollection
If (seriesInChart.Count > 1) Then
Set chartSeries = theChart.SeriesCollection("Actual Work")
Debug.Print "Value of the Actual Work series, for task " & chartSeries.XValues(1) _
& ": " & chartSeries.Values(1)
End If
End If
End Sub
For example, running the GetSeriesValue macro on a chart that includes a plot of actual work for tasks, could have the following output: Value of the Actual Work series, for task T1: 16
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.