View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Trendline Data

If you mean to get the polynomial coefficients, try something
like the following:

Dim TL As Trendline
Dim A As Double, B As Double, C As Double, D As Double, E As
Double, F As Double, G As Double
Dim S As String
Dim Arr As Variant
Dim Pos As Integer
Set Ser = Chart1.SeriesCollection(1)
Set TL = Ser.Trendlines.Add(xlPolynomial, 6) ' change 6 to
appropriate order
TL.DisplayEquation = True



TL.DataLabel.NumberFormat = "0.000000000000000"
S = TL.DataLabel.Text
Pos = InStr(1, S, "=")
S = Mid(S, Pos + 1)
S = Replace(S, " + ", "|+")
S = Replace(S, " - ", "|-")
Arr = Split(S, "|")

A = 0: B = 0: C = 0: D = 0: E = 0: F = 0: G
= 0
' g
Pos = InStr(1, Arr(LBound(Arr) + 0), "x")
G = CDbl(Left(Arr(LBound(Arr) + 0), Pos - 1))

' f
Pos = InStr(1, Arr(LBound(Arr) + 1), "x")
F = CDbl(Left(Arr(LBound(Arr) + 1), Pos - 1))

' e
Pos = InStr(1, Arr(LBound(Arr) + 2), "x")
E = CDbl(Left(Arr(LBound(Arr) + 2), Pos - 1))

' D
Pos = InStr(1, Arr(LBound(Arr) + 3), "x")
D = CDbl(Left(Arr(LBound(Arr) + 3), Pos - 1))

' c
Pos = InStr(1, Arr(LBound(Arr) + 4), "x")
C = CDbl(Left(Arr(LBound(Arr) + 4), Pos - 1))

' b
Pos = InStr(1, Arr(LBound(Arr) + 5), "x")
B = CDbl(Left(Arr(LBound(Arr) + 5), Pos - 1))

' a
A = CDbl(Arr(UBound(Arr)))



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"MF_gyps" wrote in message
...
I am looking for an Excel function or Excel VB Macro function

that will allow
me access to the actual data for a chart polynomial trendline.
Does this functionality exist?