IF/AND Statement with Multiple Conditions

ACF0303

New Member
Joined
Aug 29, 2013
Messages
41
Greetings,

I could certainly use some expert help with this formula. I am trying to accomplish the following:

If Cell H7 < 0, then put in "q"
If Cell H7 is greater than 0 and less than 1, put in "u"
If Cell H7 is greater than 1 and less than 5, put in "{"
If Cell H7 is greater than 5, put in "p"

What I came up with:

IF(H7<0,"q",IF(H7>0,AND(H7<1,"u",IF(H7>1,AND(H7<5,"{","p")))))e

The error I am getting indicates there is something wrong with the third IF statement. Any help would be greatly appreciated!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I am trying to accomplish the following:
If Cell H7 < 0, then put in "q"
If Cell H7 is greater than 0 and less than 1, put in "u"
If Cell H7 is greater than 1 and less than 5, put in "{"
If Cell H7 is greater than 5, put in "p"

What I came up with:
IF(H7<0,"q",IF(H7>0,AND(H7<1,"u",IF(H7>1,AND(H7<5,"{","p")))))e

The error I am getting indicates there is something wrong with the third IF statement.

The correct syntax is:

=IF(H7<0,"q",IF(AND(H7>=0,H7<1),"u",IF(AND(H7>=1,H7<5),"{","p")))

But you are over-specifying the logic. Since Excel evaluates the IF() arguments left to right, you can write:

=IF(H7<0,"q",IF(H7<1,"u",IF(H7<5,"{","p")))

And be sure you truly want <0, <1 and <5. Note that the alternative to "less than 0" is not "greater than 0". Instead, it is "greater than or equal to 0". Or perhaps you meant to say "less than or equal to 0" and "greater than 0".

PS.... Alternatively, you could write:

=LOOKUP(H7,{-1E300,0,1,5},{"q","u","{","p"})

-1E300 is an arbitrary "large" negative number (i.e. large in magnitude).
 
Last edited:
Upvote 0
This should work

=IF(H7>5,"p",IF(AND(H7>1,H7<5)=TRUE,"{",IF(AND(H7>0,H7<1)=TRUE,"u",IF(H7<0,"q"))))
 
Upvote 0
Thanks for the quick response. I tried both suggested formulas and I am running into a different issue. Cell H7 = 2.12% and should return "{", however it is returning "u" I know it is probably something silly.....for example, should I be using % instead of whole numbers?
 
Upvote 0
Thanks for the quick response. I tried both suggested formulas and I am running into a different issue. Cell H7 = 2.12% and should return "{", however it is returning "u" I know it is probably something silly.....for example, should I be using % instead of whole numbers?

2.12% is read by Excel as 0.0212, which falls into your category of If Cell H7 is greater than 0 and less than 1, put in "u".

If you are using percentages as your values in H7, all the values will give you "u", since they all go from 0 to 1 (or 0% to 100%)
 
Upvote 0
I knew it was something silly. Thanks so much for the quick response (again). I will go have more coffee.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,825
Members
449,096
Latest member
Erald

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