Why not let XL do the work for you?
Trendline coefficients
http://www.tushar-mehta.com/excel/tips/trendline_coefficients.htm
If you must do it yourself, suppose you have the x and y values in cols.
A and B starting with row 2. Designate some cells as the coefficient
cells. How many will depend on the kind of equation you are trying to
fit. Then, for each x value, compute f(x) using the coefficient cells.
Suppose these values are in column C. Then, in, say, column D,
calculate the square of the difference between the Y value and the f(x)
computed value. Finally, calculate the sum of the values in column D.
Now, minimize the sum of square-of-differences cell using Solver. The
'by changing cells' will be the coefficient cells. The objective will
be to minimize the sum-of-squares cell.
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005