VLookup between two values

ClaireEx

New Member
Joined
Jun 19, 2015
Messages
3
Hi all,

I hope this hasn't been answered elsewhere but I haven't found anything.

I have three columns of data. For each value in column C, I want to determine if it falls between two values in the same row in column A and B

e.g. if C1 = 30, A20=25 and B20=40, I want to return "TRUE" in D1.

I tried =VLOOKUP(C1, A:B, 2, TRUE) but the problem is that if C is NOT between two values on the same row in columns A and B, it just returns the nearest value from one of the columns.

All I want is to differentiate values in column C that fall DO between any pair of values in A and B from values that DON'T.

Any suggestions hugely appreciated! Thanks in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

gaz_chops

Well-known Member
Joined
Apr 29, 2003
Messages
6,485
Platform
  1. MacOS
Welcome to the forum.

Try

=IF(COUNTIFS($A$1:$A$30,"<"&C1,$B$1:$B$30,">"&C1),"True","")
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,717
Office Version
  1. 365
Platform
  1. Windows
Hi. Im slightly confused. How is C1 in the same row as A20 and B20? Aside from that I thought you wanted this:

=IF(AND(C1 < B1,C1 > A1),TRUE,FALSE)
 

ClaireEx

New Member
Joined
Jun 19, 2015
Messages
3
Hi. Im slightly confused. How is C1 in the same row as A20 and B20? Aside from that I thought you wanted this:

=IF(AND(C1 < B1,C1 > A1),TRUE,FALSE)

Hi thanks for replying

So A and B are positionally related to one another, but C are unrelated values. So for example say I have this:

ABCD
10207FALSE
3540150TRUE
506048FALSE
708015TRUE
100200250FALSE

<tbody>
</tbody>

D2 is TRUE because C2 is between a pair of values in A and B (A5-B5, 100-200).
D4 is TRUE because C4 is between a pair of values in A and B (A1-B1, 10-20).
The rest are FALSE because they don't fall within any of the value pairs.

Is that more clear?
 

gaz_chops

Well-known Member
Joined
Apr 29, 2003
Messages
6,485
Platform
  1. MacOS

ADVERTISEMENT

Did you try my formula?
 

gaz_chops

Well-known Member
Joined
Apr 29, 2003
Messages
6,485
Platform
  1. MacOS
You're welcome, if a value in C is = to A or B it doesn't say true, if you want it to, simply add = into the formula,

=IF(COUNTIFS($A$1:$A$30,"<="&C1,$B$1:$B$30,">="&C1),"True","")
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,657
Messages
5,838,631
Members
430,558
Latest member
Krampus

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
Top