Add Method (Trendlines Collection)

Applies To

Trendlines Collection.

Description

Creates a new Trendline.

Syntax

object.Add(type, order, period, forward, backward, intercept, displayEquation, displayRSquared, name)

object

Required. The Trendlines object.

type

Optional. Specifies the trendline type (one of xlLinear, xlLogarithmic, xlExponential, xlPolynomial, xlMovingAvg, or xlPower). If omitted, the default is xlLinear.

order

Required if type is xlPolynomial. Specifies the trendline order. Must be an integer from two to six, inclusive.

period

Required if type is xlMovingAvg. Specifies the trendline period. Must be an integer greater than one and less than the number of data points in the series you are adding a trendline to.

forward

Optional. Sets the number of periods (or units on a scatter chart) that the trendline extends forward.

backward

Optional. Sets the number of periods (or units on a scatter chart) that the trendline extends backward.

intercept

Optional. Sets the trendline intercept. If omitted, the intercept is automatically set by the regression.

displayEquation

Optional. True if the equation of the trendline is displayed on the chart (in the same data label as the R-squared value).

displayRSquared

Optional. True if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation).

name

Optional. Specifies the name of the trendline as text. If this argument is omitted, an automatically generated name is used.

See Also

Backward Property, DisplayEquation Property, DisplayRSquared Property, Forward Property, Intercept Property, Order Property, Period Property.

Example

This example creates a new linear trendline in Chart1.


ActiveWorkbook.Charts("Chart1").SeriesCollection(1).Trendlines.Add