I am trying to interpolate between two values that I need to look up. The problem is that the range of values that I need to interpolate for will change. How do I set a range that will adjust to the parameters I need it to? Also, I have left out the interpolation part so any help on this would be greatly appreciated too. This is what I have so far
Code:
max = Application.max(rng2)
For j = 1 To max
'k is the number of rows for that specific entry enabling us to set the variable range to that number of rows
k = Application.CountIf(rng2, j)
If c2 > 0 Then
c1 = c2 + 1
Else: c1 = 2
End If
c2 = c1 + (k - 1)
'^^^above checks out
Set rngcurrent = Range(Cells(c1, 1), Cells(c2, 20))
'Interpolate for N-S and E-W at the same zD as input for others
' b3 = zD
' b1 = Application.Large(rngcurrent, Application.CountIf(rngcurrent, ">" & b3) + 1)
' b2 = Application.Small(rngcurrent, Application.CountIf(rngcurrent, "<" & b3) + 1)
' n_s1 = Application.VLookup(b1, rngcurrent, 14, True)
' n_s2 = Application.VLookup(b2, rngcurrent, 14, True)
' If b3 - b1 = 0 Then
' n_s3 = n_s1
' Else
' n_s3 = n_s1 + (b3 - b1) * ((n_s2 - n_s1) / (b2 - b1))
' End If
' e_w1 = Application.VLookup(b1, rngcurrent, 15, True)
' e_w2 = Application.VLookup(b2, rngcurrent, 15, True)
' e_w3 = e_w1 + (b3 - b1) * ((e_w2 - e_w1) / (b2 - b1))