water = Round((1 - solidpercent) * tph / (solidpercent), N) End Function Function pulp(tph, spgr, solidpercent, N) pulp = Round((1 - solidpercent) * tph / (solidpercent) + tph / spgr, N) End Function Function pulpdensity(solidpercent, spgr, N) pulpdensity = Round(1 / ((solidpercent / spgr) + (1 - solidpercent)), N) End Function Function InterpolateL(lookup_value, known_xs, known_ys) Dim Dim Dim Dim Dim
pointer As Integer X0 As Double Y0 As Double X1 As Double Y1 As Double
'Following line added to prevent extrapolation
If lookup_value < Application.Min(known_xs) Or lookup_value > Application.Max(kno wn_xs) Then InterpolateL = CVErr(xlErrRef): Exit Function End If pointer = Application.Match(lookup_value, known_xs, 1) X0 = known_xs(pointer) Y0 = known_ys(pointer) X1 = known_xs(pointer + 1) Y1 = known_ys(pointer + 1) InterpolateL = Y0 + (lookup_value - X0) * (Y1 - Y0) / (X1 - X0) End Function Function InterpolateL1(lookup_value) Dim pointer As Integer Dim X0 As Double Dim Y0 As Double Dim X1 As Double Dim Y1 As Double 'Following line added to prevent extrapolation If lookup_value < Application.Min(known_xs) Or lookup_value > Application.Max(kno wn_xs) Then InterpolateL = CVErr(xlErrRef): Exit Function End If known_xs = Sheet2!a2: a8 'known_ys = Sheet2!b2: b8 pointer = Application.Match(lookup_value, known_xs, 1) X0 = known_xs(pointer) Y0 = known_ys(pointer) X1 = known_xs(pointer + 1) Y1 = known_ys(pointer + 1) InterpolateL = Y0 + (lookup_value - X0) * (Y1 - Y0) / (X1 - X0) End Function