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

Active Member
Joined
Apr 24, 2018
Messages
251
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

Active Member
Joined
Apr 24, 2018
Messages
251
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

Active Member
Joined
Apr 24, 2018
Messages
251
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,972
How about:

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

Forum statistics

Threads
1,081,932
Messages
5,362,214
Members
400,672
Latest member
ExcelGrasshopper

Some videos you may like

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...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top