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

Trendlines.Add Method (PowerPoint)

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

Creates a new trendline.

Syntax

expression. Add( Type, Order, Period, Forward, Backward, Intercept, DisplayEquation, DisplayRSquared, Name )

expression A variable that represents a Trendlines object.

Parameters

NameRequired/OptionalData TypeDescription
TypeOptionalXlTrendlineTypeOne of the enumeration values that specifies the trendline type. The default is xlLinear.
OrderOptionalVariantThe trendline order. Required ifType is set to xlPolynomial. If specified, the value must be an integer from 2 through 6.
PeriodOptionalVariantThe trendline period. Required ifType is set to xlMovingAvg. If specified, the value must be an integer greater than 1 and less than the number of data points in the series to which you are adding a trendline.
ForwardOptionalVariantThe number of periods (or units on a scatter chart) that the trendline extends forward.
BackwardOptionalVariantThe number of periods (or units on a scatter chart) that the trendline extends backward.
InterceptOptionalVariantThe trendline intercept. If specified, the value must be a double-precision floating-point number. If omitted, the intercept is automatically set by the regression, and the InterceptIsAuto property of the resulting Trendline object is set to True.

Note This parameter is applicable only ifType is set to xlExponential, xlLinear, or xlPolynomial.

| | DisplayEquation|Optional|Variant|True to display the equation of the trendline on the chart (in the same data label as the R-squared value). The default is False.| | DisplayRSquared|Optional|Variant|True to display the R-squared value of the trendline on the chart (in the same data label as the equation). The default is False.| | Name|Optional|Variant|The name of the trendline. If omitted, Microsoft Word generates a name, and the NameIsAuto property of the resulting Trendline object is set to True.|

Return Value

A Trendline object that represents the new trendline.

Example

Note Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

The following example creates a new linear trendline for the first chart in the active document.

With ActiveDocument.InlineShapes(1) 
    If .HasChart Then 
        .Chart.SeriesCollection(1).Trendlines.Add 
    End If 
End With

See also

Concepts

Trendlines Object

© 2018 Microsoft