Lookup table between two ranges

L

LROCCO

Hi,

I would like to lookup a value (entered in cell D1) in the table
below. For example if it were between 0 and 2 it would return R1, if
it were between 3 and 5 it would return R2, etc.

(starting in column A1)
0 2 R1
3 5 R2
6 8 R3

Any help would be gratefully received
 
S

Stephen

LROCCO said:
Hi,

I would like to lookup a value (entered in cell D1) in the table
below. For example if it were between 0 and 2 it would return R1, if
it were between 3 and 5 it would return R2, etc.

(starting in column A1)
0 2 R1
3 5 R2
6 8 R3

Any help would be gratefully received

You can do this easily with a non-exact vlookup. You don't need the second
column; just enter 0,3,6 in A1:A3 and R1,R2,R3 in B1:B3. Put the value you
want to lookup in D1 and use this formula:
=VLOOKUP(D1,A1:B3,2,1)
 
L

LROCCO

You can do this easily with a non-exact vlookup. You don't need the second
column; just enter 0,3,6 in A1:A3 and R1,R2,R3 in B1:B3. Put the value you
want to lookup in D1 and use this formula:
=VLOOKUP(D1,A1:B3,2,1)

Thanks for that, works great.

I guess it would be more difficult if the numbers didn't follow on
from each other, i.e.

2 4 R1
7 10 R2
12 17 R3
 
S

Stephen

LROCCO said:
Thanks for that, works great.

I guess it would be more difficult if the numbers didn't follow on
from each other, i.e.

2 4 R1
7 10 R2
12 17 R3

Well, what would you want to be returned for 5, etc.? You could make the
lookup table like this, for example:
2 R1
5 "invalid"
7 R2
11 "invalid"
12 R3
18 "invalid"
 
L

LROCCO

Well, what would you want to be returned for 5, etc.? You could make the
lookup table like this, for example:
2 R1
5 "invalid"
7 R2
11 "invalid"
12 R3
18 "invalid"- Hide quoted text -

- Show quoted text -

Yes of course, makes sense, nice one
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top