[COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]
[COLOR=darkblue]Sub[/COLOR] AddTrendLinesToEachSeriesInChart()
[COLOR=darkblue]Dim[/COLOR] oChart [COLOR=darkblue]As[/COLOR] Chart
[COLOR=darkblue]Dim[/COLOR] oSeries [COLOR=darkblue]As[/COLOR] Series
[COLOR=darkblue]Dim[/COLOR] oTrendLine [COLOR=darkblue]As[/COLOR] Trendline
[COLOR=green]' Assign the chart to an object variable[/COLOR]
[COLOR=darkblue]Set[/COLOR] oChart = Worksheets("Sheet1").ChartObjects("Chart 1").Chart
[COLOR=green]' Remove any existing trendlines for each series in the chart[/COLOR]
[COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] oSeries [COLOR=darkblue]In[/COLOR] oChart.SeriesCollection
[COLOR=darkblue]While[/COLOR] oSeries.Trendlines.Count > 0
oSeries.Trendlines(1).Delete
[COLOR=darkblue]Wend[/COLOR]
[COLOR=darkblue]Next[/COLOR] oSeries
[COLOR=green]' Add trendlines for each series in the chart[/COLOR]
[COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] oSeries [COLOR=darkblue]In[/COLOR] oChart.SeriesCollection
[COLOR=darkblue]Set[/COLOR] oTrendLine = oSeries.Trendlines.Add
oTrendLine.Type = xlLinear
[COLOR=darkblue]Next[/COLOR] oSeries
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]