I found the use of David's code to be pretty well described in the
leading comments of the code. It is hard to know how to help you, since
you give so little information about where you are having problems.
When I pasted the code into the macro editor, some lines improperly
wrapped, so I had to scan through and fix the wrapping, but the
locations are pretty obvious visually. You will either see black lines
in the documentation area (green comments), or red incomplete code
snippets in the executable area (among black code lines). In both types
of cases, join the offending bits to the previous line.
Two limitations that are not documented in the code are
- the code only works with charts that are on a worksheet, not on a
separate graph sheet.
- the code does not handle polynomial coefficients of +/-1 (the parser
needs to see an asterisk to separate the coefficient from the variable).
I imagine that either limitation could be removed without too much
effort, but I have not actually attempted it.
If you open a new workbook and create an unnamed single-series chart
with a trendline on the the first page, then
=TLcoef("Sheet1","Chart 1",1,1)
will extract its coefficients. You must select enough cells to hold all
the coefficients and array enter (Ctrl-Shift-Enter) the formula to see
all the coefficients. TLcoef() only extracts to the precision that the
equation is displayed on the chart, so you must take responsibility for
formatting to enough figures to be meaningful.
Note that the algorithms for LINEST() and LOGEST() were improved in
Excel 2003, so there is no reason to use this code if you have Excel 2003.
Jerry