Class Trendline (PowerPoint VBA)

The class Trendline represents a trendline in a chart.

The main procedures of class Trendline are Delete, Select and Trendlines.Add

Set

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

Dim trnln as Trendline
Set trnln = ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(Index:=1)

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

Themes

Some procedures in this class have been grouped together in themes and are described on separate theme pages

Sort/Order with its procedures Border and Order
Format with its procedures ClearFormats and Format
Display/Show with its procedures DisplayEquation and DisplayRSquared

Methods

These are the main methods of the Trendline class

Delete - Deletes the object.

ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).Delete

Select - Selects the object.

ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).Select

Trendlines.Add - Creates a new trendline.

Dim trnln As Trendline
Set trnln = ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines.Add()

Other Methods

SetProperty -

Dim strId As String: strId = 
ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).SetProperty Id:=strId, Value:=

Properties

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

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).Backward2 = 5

DataLabel returns the data label that is associated with the trendline.

Dim dtlDataLabel As DataLabel
Set dtlDataLabel = ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).DataLabel

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

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).Forward2 = 5

Index returns the index number of the object within the collection of similar objects.

Dim lngIndex As Long
lngIndex = ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).Index

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

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).Intercept = 5

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

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).InterceptIsAuto = True

Name returns or sets name of the object.

ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).Name =

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

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).NameIsAuto = True

Parent returns the parent for the specified object. Read-only object.

Dim objParent As Object
Set objParent = ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines(1).Parent

Period returns or sets the period for the moving-average trendline.

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).Period = 5

Type returns or sets the trendline type.

ActivePresentation.Slides(1).Shapes(1).Chart.FullSeriesCollection(1).Trendlines(1).Type = xlExponential

Trendlines.Count returns the number of objects in the collection.

Dim lngCount As Long
lngCount = ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines.Count

Trendlines.Parent returns the parent for the specified object. Read-only object.

Dim objParent As Object
Set objParent = ActiveWindow.RangeFromPoint.Chart.FullSeriesCollection(1).Trendlines.Parent