IF / AND with exceptions

RJB78

Board Regular
Joined
Aug 8, 2016
Messages
69
Office Version
  1. 365
Hi All - Looking for help with a problem. I have an IF function with an AND inside it, the AND has multiple rules. Currently, the formula works great but I am looking for one of the AND rules to allow for an exception based on words in a separate cell.

Current Formula:

=IF(AND(O1>2000,AW1>=0.04,AW1<=AX1,AY1="Yes"),"Yes","No")
Broken down: O1 must be larger than 2000; AW1 must be greater than/equal to .04; AW1 must be less than/equal to AX1; AY1 must contain "YES". IF all of this is true, "yes", if not, "no".

The exception I would like to put in is for the AW1<=AX1 part. I would like this to remain true, UNLESS column AG has certain words in it, specifically "WATER" and "LAND". If it contains either of those two words, I don't care if AW1 is less than AX1.

I should mention that the word Water and Land is not the only word in the AG column (Salt water, fresh water). Is it possible to just use the qualifier "water" or will I need to include qualifiers for both fresh and salt? I am open to either.

Thank you in advance!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I think this does what you want but im sure it can be written a lot cleaner as well:

=IF(AND(O1>2000,AW1>=0.04,AY1="Yes"),IF(OR(ISNUMBER(SEARCH("Water", AG1)), ISNUMBER(SEARCH("Land", AG1))), "Yes", IF(AW1<=AX1, "Yes","No")), "No")
 
Upvote 0
For example i think this does the same:

=IF(AND(O1>2000,AW1>=0.04,AY1="Yes"),IF(OR(ISNUMBER(SEARCH("Water", AG1)), ISNUMBER(SEARCH("Land", AG1)), AW1<=AX1), "Yes","No"), "No")

but i'm also sure the

ISNUMBER(SEARCH("Water", AG1)), ISNUMBER(SEARCH("Land", AG1))

can be written as something like this:

isnumber(search({"water", land"}, AG1))

but whenever i try this method it never wants to work for me so someone might be able to chip in on that bit.
 
Upvote 0
Solution
Final Fight - Thank you! This seems to have worked. I appreciate it.
 
Last edited:
Upvote 0
Hello - What would the formula be if I wanted to ignore the AW1<=AX1 only if AG contained "land'. Not 'water' any more.

Thank you
 
Upvote 0
If i'm reading it correctly, do you mean this like this?

=IF(AND(O1>2000,AW1>=0.04,AY1="Yes"),IF(OR(ISNUMBER(SEARCH("Land", AG1)), AW1<=AX1), "Yes","No"), "No")
 
Upvote 0
That specific formula returned #value . But yes, that's the idea. I no longer need the formula to ignore "water", just "land"
 
Upvote 0
How about:

=IF(AND(O1>2000,AW1>=0.04,OR(AW1<=AX1,COUNTIF(AG1,"*land*")),AY1="Yes"),"Yes","No")
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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