I don't know the specifics of how you're spreadsheet is setup, but
here's how I setup and solved a simplified version of the problem.
It's not a single cell formula, but you could always put the
intermediate steps in hidden columns or out of the way columns. I'm
also assuming that you will return n/a from the UDF in case of an
error. Basically it boils down to setting up a weighted regression
where the points with error values are weighted 0.
input regression
X, Y, wt, X, Y
0, -1 =if(iserror(b2),0,1), =a2*c2, =if(iserror(b2),0,b2)
1, 0 (columns c-e copied down)
2, =na()
3, 2
Columns C and D become the X matrix in the regression and column e
becomes the y matrix. Where Y=n/a, that point will be ignored
(weighted 0) in the regression. To return the slope, I used
=index(linest(e2:e5,c2:d5,false),1).
Does that help?
--
MrShorty
------------------------------------------------------------------------
MrShorty's Profile:
http://www.excelforum.com/member.php...o&userid=22181
View this thread:
http://www.excelforum.com/showthread...hreadid=493537