VLookup between two values

ClaireEx

New Member
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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

gaz_chops

Well-known Member
Welcome to the forum.

Try

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

steve the fish

Well-known Member
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
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)

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

 A B C D 10 20 7 FALSE 35 40 150 TRUE 50 60 48 FALSE 70 80 15 TRUE 100 200 250 FALSE

<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

Did you try my formula?

ClaireEx

New Member
Welcome to the forum.

Try

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

This works! Thank you!

gaz_chops

Well-known Member
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","")

Replies
6
Views
92
Replies
2
Views
69
Replies
3
Views
45
Replies
4
Views
165
Replies
2
Views
49

1,127,167
Messages
5,623,130
Members
415,956
Latest member
Footballtend

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.

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

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