leal72
12-05-2016, 01:33 PM
I am trying to place the Trendline equation into a cell. It has ended up working a couple of times but when I go back and retest the code it doesn't work. The Range "Q" is blank. Any help is appreciated
ChartOne.SeriesCollection(WsName).Trendlines.Add Type:=xlLinear, Name:="Linear Trend" & " " & WsName
stCount = ChartOne.SeriesCollection.Count
Sheets("SummaryCharts").Range("P" & stCount).Value = "Linear Trend" & " " & WsName
ChartOne.SeriesCollection(stCount).Trendlines(stCount).DisplayEquation = True
tLabel = ChartOne.SeriesCollection(stCount).Trendlines(stCount).DataLabel.Text
Sheets("SummaryCharts").Range("Q" & stCount).Value = tLabel
ChartOne.SeriesCollection(WsName).Trendlines.Add Type:=xlLinear, Name:="Linear Trend" & " " & WsName
stCount = ChartOne.SeriesCollection.Count
Sheets("SummaryCharts").Range("P" & stCount).Value = "Linear Trend" & " " & WsName
ChartOne.SeriesCollection(stCount).Trendlines(stCount).DisplayEquation = True
tLabel = ChartOne.SeriesCollection(stCount).Trendlines(stCount).DataLabel.Text
Sheets("SummaryCharts").Range("Q" & stCount).Value = tLabel