Lookup between two values

Gareth Brown

Board Regular
Joined
Jul 29, 2002
Messages
52
Hi all,

Is there a neater way than using nested ifs to achieve a vlookup BETWEEN two numbers?

ie. have the equivalent of a lookup table except i need a value returned if it is between the numbers:

Min;Max;Return value
60;110;0.455
-10;60;0.318
110;150;0.136
150;(inf);0.091
-(inf);-10;0.000

So if I have 80 (between 60 and 110) 0.455 is returned.

Any ideas?

thanks in advance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Fraid I didn't understand that Paddy!

The lookup table refers to temperatures. I am analysing 1067 pipe temperatures to see which ones are the most critical - if that helps? So yeah, the temps are all over the place (inc. decimals) so I only need to know which lines fall within each bound.
This message was edited by Gareth Brown on 2002-09-17 22:41
 
Upvote 0
Gareth,

You can still use VLOOKUP, but exclude the 0 in the fourth argument, so the match doesn't have to exact. As long as the lookup table is set up correctly, VLOOKUP will return the correct value. See help for the way it works.

If VLOOKUP can't find lookup_value, and range_lookup is TRUE, it uses the largest value that is less than or equal to lookup_value.


Richard
 
Upvote 0
Thanks mate, i'll give it a whirl.

I ended up using Index(..,Match(..,..,1),..) but yeah - works the same.
This message was edited by Gareth Brown on 2002-09-17 23:32
 
Upvote 0
3 options for multi key lookups here:
TOU Vacant Process1.xls
ABCDE
1MinMaxReturnvalue
2601100.455
3-10600.318
41101500.136
51501.00E+3080.091
6-1.00E+308-100
7
8
9
10CheckValue80
11Sumproduct0.455
12ArrayedIndex0.455
13
14DgetVersion
15MinMaxReturn
16<=80>=800.455
17
Sheet3



note:

1) I have changed your (inf) & -(inf) to + and - 9.99999999999999E+307 respectively (this being the largest number excel can hold).
2) If the value can fall between 2 or more sets of ranges (because the ranges are not mutually exclusive), both the index & the sumproduct will give erroneous results. Only the dget will return an error value. (Although you could do some error checking first if you thought this a risk)
3) Dget is a pain to use if you want to check lots of values.


Paddy
This message was edited by PaddyD on 2002-09-17 22:56
 
Upvote 0
The caveat re the sumproduct is a big one - only use it if you can guarantee that there will only ever be one match in the range!

Paddy
 
Upvote 0

Forum statistics

Threads
1,214,377
Messages
6,119,183
Members
448,872
Latest member
lcaw

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