IF / AND with exceptions

RJB78

Board Regular
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.

Finalfight40

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

Active Member
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
Final Fight - Thank you! This seems to have worked. I appreciate it.

Last edited:

RJB78

Board Regular
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

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

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

RJB78

Board Regular
That worked. Thank you Eric

1,082,277
Messages
5,364,197
Members
400,786
Latest member
ismi88

This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...