PDA

View Full Version : Put linear trendline equation into cell



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

mana
12-06-2016, 05:05 AM
ChartOne.SeriesCollection(stCount).Trendlines(stCount).DisplayEquation = True
DoEvents
tLabel = ChartOne.SeriesCollection(stCount).Trendlines(stCount).DataLabel.Text

leal72
12-06-2016, 10:05 AM
Thanks but it's not working. I don't get any errors but the cells where the Trend line equation should be is empty.

mana
12-07-2016, 04:26 AM
Instead of "DoEvents"


try1

For i = 1 To 5
DoEvents
Next
try2

Application.Wait Now + TimeValue("0:00:01")


try3

Application.ScreenUpdating = True


try4

ChartOne.Parent.Activate

Kenneth Hobs
12-07-2016, 07:42 AM
It would be easier to help if you attached a sample file.

leal72
12-07-2016, 10:06 AM
Thank you very much!

Try4 did the trick.

leal72
12-07-2016, 10:31 AM
17783


It would be easier to help if you attached a sample file.
Thank you for your time

Here a sample file. The code places multiple files into a single workbook, it graphs and plots each one as it goes. The section of code I had posted was the part that was giving me trouble. Should the full code be posted also?