Skip to content

Instantly share code, notes, and snippets.

@superyngo
superyngo / interp2d.bas
Created February 9, 2022 05:58 — forked from pyRobShrk/interp2d.bas
Excel UDF for bilinear interpolation
Function Int2d(rowLookup As Double, colLookup As Double, lookupRange As Range) As Double
'This function performs 2 dimensional linear interpolation using built-in linear functions
'Lookup range includes column and row lookup values
Dim Row, col As Integer
Dim RowVals, ColVals, lookup As Variant
Dim sl1, sl2, sl3, int1, int2, int3, col1, col2 As Double
Row = 1
col = Row
On Error Resume Next
Row = WorksheetFunction.Match(rowLookup, lookupRange.Offset(1, 0).Columns(1), 1)