IF / AND with exceptions

RJB78

Board Regular
Joined
Aug 8, 2016
Messages
54
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!
 

Finalfight40

Board Regular
Joined
Apr 24, 2018
Messages
239
Office Version
365
Platform
Windows
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")
 

Finalfight40

Board Regular
Joined
Apr 24, 2018
Messages
239
Office Version
365
Platform
Windows
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.
 

RJB78

Board Regular
Joined
Aug 8, 2016
Messages
54
Final Fight - Thank you! This seems to have worked. I appreciate it.
 
Last edited:

RJB78

Board Regular
Joined
Aug 8, 2016
Messages
54
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
 

Finalfight40

Board Regular
Joined
Apr 24, 2018
Messages
239
Office Version
365
Platform
Windows
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")
 

RJB78

Board Regular
Joined
Aug 8, 2016
Messages
54
That specific formula returned #value . But yes, that's the idea. I no longer need the formula to ignore "water", just "land"
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
8,784
How about:

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

Forum statistics

Threads
1,077,662
Messages
5,335,561
Members
399,024
Latest member
rokcel389

Some videos you may like

This Week's Hot Topics

Top