View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
MrShorty[_22_] MrShorty[_22_] is offline
external usenet poster
 
Posts: 1
Default interesting interpolation


Rats, I was afraid it would be more complicated than the sample data set
indicated.

I'm not real good with Excel's built in lookup functions, but I expect
someone out there can figure out a combination of VLOOKUP, HLOOKUP,
INDEX, MATCH, etc. that will extract the desired boundary points. If
they do, I expect it will be a complex, ugly looking function.

If it were me, I'd probably build a UDF to handle this scenario.
Something like:

Function 2DLINTERP(lookuptable as range, newA as double, newB as
double) as double
rowA=0
'loop through rows to locate the interval containing newA
Do
rowA=rowA+1
loop until lookuptable.cells(rowA,1).value = newA
colB=0
'loop through columns to locate interval containing newB
Do
colB=colB+1
loop until lookuptable.cells(1,colB).value = newB
'now boundary points are located in lookuptable.cells(rowA-1,colB-1)
through lookuptable.cells(rowA,colB)
2DLINTERP=interpolation formula
end function

Note that this function assumes that A and B are sorted in ascending
order, and doesn't have any code to deal with cases where newA or newB
are outside the range of A or B. I'll let you decide how to deal with
those cases. I haven't tested it either, so it will probably need some
debugging.

That should be a start for you.


--
MrShorty
------------------------------------------------------------------------
MrShorty's Profile: http://www.excelforum.com/member.php...o&userid=22181
View this thread: http://www.excelforum.com/showthread...hreadid=472841