btaarm.blogg.se

Make a trendline active equation excel
Make a trendline active equation excel













make a trendline active equation excel

To increase the accuracy of the trend series, select more than two starting values. Select at least two cells that contain the starting values for the trend. The resulting product and each subsequent product is then multiplied by the step value. In a growth trend series, the starting value is multiplied by the step value to get the next value in the series.

make a trendline active equation excel

StrEquation = s.Trendlines(1).DataLabel.Tip: To manually control how the series is created, on the Edit menu, point to Fill, and then click Series.Ĭreate an exponential growth trend series In the loop you can check the value of the equation and exit when it's non-empty (of if some max time has passed so you don't end up stuck in the loop forever) ThemeColor = 5 'msoThemeColorAccent enumeration starts at 5 Try adding a loop with DoEvents to allow Excel to "catch up" with your code. UpToX = Split(strEquation, "x") 'upToX = "y = m"ĪfterEquals = Split(upToX(0), " ") 'afterEquals = "m" StrEquation = s.Trendlines(1).DataLabel.Text 'strEquation = "y = m*x + b" 'THIS WORKS WHEN STEPPING THROUGH, but NOT RUNNING? S.Trendlines(1).DisplayEquation = True 'displays the equation for each new trendline S.Trendlines.Add 'adds a trendline to series (s) 'Debug.Print s.Name 'debug print which series 's' is being manipulated Here is my script that runs on an active chart: ThemeColor = 5 'msoThemeColorAccent enumeration starts at 5įor Each s In ActiveChart.SeriesCollection Subscript out of range on the line afterEquals = Split(upToX(0), " "). This is a very repeatable error where I can step through all series and extract all equations, or step through the first trendline and then run the rest and the script will break on the second trendline with Run-time error 9. I can extract the trendline equations when stepping through the script using F8, but when I remove breakpoints and run with F5 s.Trendlines(1).DataLabel.Text only returns an empty string to strEquations. I am trying to build a collection of the slopes from each trendline in an active chart.















Make a trendline active equation excel