Class Trendline (Excel VBA)

The class Trendline represents a trendline in a chart.

Member in collection

Item

To use a Trendline class variable it first needs to be instantiated, for example

Dim trnln as Trendline
Set trnln = ActiveChart.FullSeriesCollection(1).Trendlines(Index:=1)

The following procedures can be used to set variables of type Trendline: Trendlines.Add and Trendlines.Item.

For Each

Here is an example of processing the Trendline items in a collection.

Dim trnln As Trendline
For Each trnln In ActiveChart.FullSeriesCollection(1).Trendlines()
	
Next trnln

ClearFormats - Clears the formatting of the object.

Delete - Deletes the object.

Select - Selects the object.

Trendlines.Add - Creates a new trendline.

Trendlines.Item - Returns a single Trendline object from the collection.

Properties

Backward2 returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward.

Border returns a Border object that represents the border of the object.

DataLabel returns a DataLabel object that represents the data label associated with the trendline.

DisplayEquation true if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value). Setting this property to True automatically turns on data labels.

DisplayRSquared true if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation). Setting this property to True automatically turns on data labels.

Format returns the ChartFormat object.

Forward2 returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward.

Index returns a Long value that represents the index number of the object within the collection of similar objects.

Intercept returns or sets the point where the trendline crosses the value axis.

InterceptIsAuto true if the point where the trendline crosses the value axis is automatically determined by the regression.

Name returns or sets a String value representing the name of the object.

NameIsAuto true if Microsoft Excel automatically determines the name of the trendline.

Order returns or sets a Long value that represents the trendline order (an integer greater than 1) when the trendline type is xlPolynomial (XlTrendlineType).

Period returns or sets the period for the moving-average trendline. Can be a value from 2 through 255.

Type returns or sets an XlTrendlineType value that represents the trendline type.

Trendlines.Count returns a Long value that represents the number of objects in the collection.

Border - Represents the border of an object.

ChartFormat - Provides access to the Office Art formatting for chart elements.

DataLabel - Represents the data label on a chart point or trendline.