Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a function that reads the coefficients of a trendline by
searching the datalabel.text It is by no means sophisticated, but it works well. It is designed only for second order polynomials and returns the a, b, or c coefficient (y=ax^2+bx+c) based on the user "reference". That is =coeff("a") returns the a coefficient. My question is....since the function doesn't truly reference anything but the code, it doesn't update when the underlying data changes. When the data changes the trendline is updated, but nothing triggers the function to "recalculate". Is there a way to reference the chart, such that when it changes the value is recalculated?.....will this even work like changing the value in a referenced cell?? Thanks, John Public Function coeff(var As String) As Double sEqn = Charts(1).SeriesCollection(1).Trendlines(1).DataLa bel.Text fst = InStr(1, sEqn, "x2") snd = InStr(fst + 1, sEqn, "x") If Mid(sEqn, fst + 3, 1) = "+" Then bsign = True Else bsign = False End If If Mid(sEqn, snd + 2, 1) = "+" Then csign = True Else csign = False End If If var = "a" Then coeff = Mid(sEqn, 5, fst - 5) ElseIf var = "b" Then If bsign = True Then coeff = Mid(sEqn, fst + 5, snd - (fst + 5)) Else coeff = "-" & Mid(sEqn, fst + 5, snd - (fst + 5)) End If ElseIf var = "c" Then If csign = True Then coeff = Mid(sEqn, snd + 4, Len(sEqn) - snd + 3) Else coeff = "-" & Mid(sEqn, snd + 4, Len(sEqn) - snd + 3) End If End If End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Extracting Trendline Coefficients | Excel Discussion (Misc queries) | |||
Extracting Trendline Coefficients | Excel Programming | |||
Trendline Coefficients | Excel Programming | |||
Coefficients of trendline | Excel Programming | |||
Trendline coefficients | Charts and Charting in Excel |