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
247
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
247
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
247
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,811
How about:

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

Forum statistics

Threads
1,078,541
Messages
5,341,061
Members
399,414
Latest member
EMW2159

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top