linear interpolation macro help

O

Oligo

say i have a table data

A B C D
1 9 15 5
2 12 19 18
3 15 22 30

when A = 1.5, it will interpolate the table array to get the corresponding B
C D values.

how do i write the macro??
 
B

Bernie Deitrick

Oligo,

Use the FORECAST function

Sub test()
Dim Str As String
Dim myVal As Double
myVal = 1.5

Str = "B: " & Application.Forecast(myVal, Range("B2:B4"), Range("A2:A4"))
Str = Str & Chr(10) & "C: " & Application.Forecast(myVal, Range("C2:C4"),
Range("A2:A4"))
Str = Str & Chr(10) & "D: " & Application.Forecast(myVal, Range("D2:D4"),
Range("A2:A4"))
MsgBox Str
End Sub

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top