Hi Mike
I hope you're still checking this!
I think the code you will need to use varies depending on what type of
trendline you are using. In my case it was a power line (my code is below
and comes with a health warning!!). In effect it returns an array where the
first element is the base number, the second element is the exponent and the
third element is the R^2 value. The inputs to the function are simply a
chart and a number identifying the index of the series (in case you have more
than one - I use an enum). As the comments state this works by extracting
the data from the trendline data label. If you want to get the information
straight from the source data then have a look he
http://www.j-walk.com/ss/excel/tips/tip101.htm
Also try doing a search on this newsgroup for 'trendline data' as there have
been a few other related queries, which is how I figured this out.
Good luck!
Private Function GetPowerTrendData(myChart As Chart, stSeries As
SERIES_TYPE) As Variant
'This function strips out the trendline data from the label
'and returns them in an array. It only works for a power trend
'curve.
Dim serData As Series
Dim tl As Trendline
Dim intPos As Integer
Dim strText As String
Dim varArr As Variant
'Assign the series and trendline variables
Set serData = myChart.SeriesCollection(stSeries)
Set tl = serData.Trendlines(1)
'Only proceed if the trendline type is a power curve
If tl.Type = xlPower Then
'Get the text of the trendline label
strText = tl.DataLabel.Text
'Find the first instance of an "=" symbol (will not need the "y=" bit
intPos = InStr(1, strText, "=")
'Replace the 'x' with a delimiter for the Split function
strText = Replace(strText, "x", "|")
'Replace the return char and R2 text with a delimiter
strText = Replace(strText, Chr(10) & "R2 = ", "|")
'Replace the text string with the end part (excluding the y=)
strText = Mid(strText, intPos + 1)
'Split the text, assign to an array and return the array
varArr = Split(strText, "|")
GetPowerTrendData = varArr
Else
MsgBox "This function can only be used for a Power trendline.",
vbExclamation, "Incorrect Trendline"
End If
End Function
"mikerr" wrote:
Even though the original poster found his own way, I would still find it
helpful if someone could still answer this for me. Thanks.
--
mikerr
------------------------------------------------------------------------
mikerr's Profile: http://www.excelforum.com/member.php...o&userid=25830
View this thread: http://www.excelforum.com/showthread...hreadid=392109