Trendlines collection (Excel Graph)
A collection of all the Trendline objects for the specified series. Each Trendline object represents a trendline in a chart. A trendline shows the trend, or direction, of data in a series.
Remarks
Use the Trendlines method to return the Trendlines collection.
Use the Add method to create a new trendline and add it to the series.
Use Trendlines (index), where index is the trendline's index number, to return a single TrendLine object.
The index number denotes the order in which the trendlines are added to the series. Trendlines(1)
is the first trendline added to the series, and Trendlines(Trendlines.Count)
is the last one added.
Example
The following example displays the number of trendlines for series one in the chart.
MsgBox myChart.SeriesCollection(1).Trendlines.Count
The following example adds a linear trendline to series one in the chart.
With myChart.SeriesCollection(1).Trendlines
.Add Type:=xlLinear, Name:="Linear Trend"
End With
The following example changes the trendline type for series one in the chart. If the series has no trendline, this example fails.
myChart.SeriesCollection(1).Trendlines(1).Type = xlMovingAvg
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for