Setting a variable range

carstenp

Board Regular
Joined
May 27, 2010
Messages
148
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))
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,216,577
Messages
6,131,511
Members
449,653
Latest member
andz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top