Table of contents
TOC
Collapse the table of content
Expand the table of content

Chart.SeriesCollection Method (Project)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

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

NameRequired/OptionalData typeDescription
IndexOptionalVariantThe name or index number of the series. If Index is not specified, the SeriesCollection method returns all of the series in the chart.
IndexOptionalVARIANT

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

Other resources

Chart Object

© 2018 Microsoft