ChTrendline Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

ChTrendlines
Aa190544.parchild(en-us,office.10).gifChTrendline
Aa190544.space(en-us,office.10).gifAa190544.parchild(en-us,office.10).gif

Represents a trendline on a chart. A trendline shows the trend, or direction, of data in a series. The ChTrendline object is a member of the ChTrendlines collection.

Using the ChTrendline object

Use the Add method of the ChTrendlines object to add a trendline to a series.

The following method and property return a ChTrendline object.

The ChTrendlines collection’s Add method

The ChTrendlines collection’s Item property

The following example adds a trendline to the first series in the first chart in Chartspace1 and then formats the trendline.

  Sub AddPolyTrendline()

    Dim serSeries1
    Dim chConstants
    Dim tlSeries1Trend

    Set chConstants = ChartSpace1.Constants

    ' Set a variable to the first series of the first chart
    ' in Chartspace1.
    Set serSeries1 = ChartSpace1.Charts(0).SeriesCollection(0)

    ' Add a trendline to the first series and return
    ' a Trendline object.
    Set tlSeries1Trend = serSeries1.Trendlines.Add

    ' Display the equation used to calculate the trendline.
    tlSeries1Trend.IsDisplayingEquation = True

    ' Set the trendline to be a polynomial trendline.
    tlSeries1Trend.Type = chConstants.chTrendlineTypePolynomial

End Sub