Input Output
1 10
2 20
3 30
If the user introduces 1.2, the result should be 12 (interpolation)
Thanks in advance,
E. Blanco
I use a simple macro function (that I wrote a while ago), and put it in
personal.xls as I use it fairly often.
HTH
Peter Hewett
------------------------------------------------
'
' Interpolation Function
' Author: P W Hewett
' Date: 1 July 1995
' Uses linear extrapolation if X is out of range!
'
Function Interp(X, XRange, YRange)
XP1 = 0
For Each c In XRange
If c > X Then Exit For
XP1 = XP1 + 1
Next c
Leng = XRange.Rows.Count - 1
If XP1 > Leng Then XP1 = Leng
If XP1 < 1 Then XP1 = 1
X0 = XRange.Cells(XP1).Value
X1 = XRange.Cells(XP1 + 1).Value
Y0 = YRange.Cells(XP1).Value
Y1 = YRange.Cells(XP1 + 1).Value
Interp = Y0 + (X - X0) * (Y1 - Y0) / (X1 - X0)
End Function
------------------------------------------------
"Enrique BLANCO" <Enrique...@cern.ch> wrote in message
news:398706AC...@cern.ch...
TREND() works for linear interpolation between two points. If your
sample table above were entered in A1:B4 (column headings in row 1),
then =TREND(B2:B3,A2:A3,1.2) will give 12.
Sent via Deja.com http://www.deja.com/
Before you buy.