Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 2.25 KB

Excel.Trendlines.Add.md

File metadata and controls

55 lines (36 loc) · 2.25 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Trendlines.Add method (Excel)
vbaxl10.chm592074
vbaxl10.chm592074
Excel.Trendlines.Add
4d86029e-3c42-2d81-69d3-94d8dc072ccd
05/18/2019
medium

Trendlines.Add method (Excel)

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

Name Required/Optional Data type Description
Type Optional XlTrendlineType The trendline type.
Order Optional Variant Variant if Type is xlPolynomial. The trendline order. Must be an integer from 2 to 6, inclusive.
Period Optional Variant Variant if Type is xlMovingAvg. The trendline period. Must be an integer greater than 1 and less than the number of data points in the series you are adding a trendline to.
Forward Optional Variant The number of periods (or units on a scatter chart) that the trendline extends forward.
Backward Optional Variant The number of periods (or units on a scatter chart) that the trendline extends backward.
Intercept Optional Variant The trendline intercept. If this argument is omitted, the intercept is automatically set by the regression.
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 value 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 value is False.
Name Optional Variant The name of the trendline as text. If this argument is omitted, Microsoft Excel generates a name.

Return value

A Trendline object that represents the new trendline.

Example

This example creates a new linear trendline on Chart1.

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

[!includeSupport and feedback]