"IF" function for up to 6 comparison values

JerryMason

New Member
Joined
Jun 2, 2022
Messages
7
Office Version
  1. 365
Hey everyone,

I have another interesting problem I can't find the answer to (exactly).

I have a value in Column A (we'll call it value A) and with a single formula I'd like to try and be able to compare it to 6 other values in cells adjacent to it (Columns B, C, D, E, F, G) and in Column H we have a formula tell us if A is:

Below B = 0
Between B and C = 1
Between C and D = 2
Between D and E = 3
Between E and F = 4
Between F and G = 5
Above G = 6

For example if A = 21 and the comparison values are ------->>> 3 | 17 | 24 | 29 | 38 | 51
The formula in H will return a "2"

*All values from B to G are sequential counting upwards, nothing is out of order.

I've tried this with two values (some form of an if(and) ) but now I'm at a loss with up to six. Is there a way to do this even?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try something like
Excel Formula:
=IFERROR(MATCH(A2,B2:G2),0)
Book1
ABCDEFGHI
221317242938512
Sheet6
Cell Formulas
RangeFormula
I2I2=IFERROR(MATCH(A2,B2:G2),0)
 
Upvote 0
Solution
not sure but does this work
=IFERROR(MATCH(A2,B2:G2,1),0)

Book2
ABCDEFGH
1
23241222321011
3
Sheet1
Cell Formulas
RangeFormula
H2H2=IFERROR(MATCH(A2,B2:G2,1),0)
 
Upvote 0
If your data is in row 1, so tested value in A1, and "limits" in B1:G1 then
Excel Formula:
=IFERROR(MATCH(A1,B1:G1),0)
shall return exactly what you need
 
Upvote 0
Another option
Excel Formula:
=IFNA(XMATCH(A2,B2:G2,-1),5)
 
Upvote 0
Thanks Guys, the IFERROR(MATCH etc worked like a charm. Its so simple, I had no idea, Learn something new every day!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,047
Members
448,940
Latest member
mdusw

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