Go Back

If Cell is X or Y and Z

We can use a nested formula that combines the IF, AND, and OR functions to test for multiple conditions. Here, we will test if a cell value fulfills X OR Y conditions and Z CONDITION. The steps below will walk through the process.

Figure 1: Result of If Cell is “Science” or “Arts” and “A”

General Formula

= IF(AND(OR(x is True, y is True), z is True),value_if_True,value_if_False)

The TRUE Value is returned only if the X OR Y CRITERIA IS TRUE and Z IS ALSO TRUE

Formula

=IF(AND(OR(B4="Science",B4="Arts"),C4="A"),"Qualified","Unsuitable")

Setting up the Data

 

  • We will set up the data by inputting the Names of Recruits in Column A
  • The discipline of the recruits are placed in Column B
  • Their chances of been hired are placed in Column C with assigned alphabets
  • Column D is where we want the formula to return the result. Qualified signifies a TRUE value and Unsuitable is a FALSE value

Figure 2: Setting up the Data

If Cell is “Science” or “Arts” and “A”

  • We will click on Cell D4
  • We will insert the formula below into the cell
    =IF(AND(OR(B4="Science",B4="Arts"),C4="A"),"Qualified","Unsuitable")
  • We will press the enter key

Figure 3: If Cell is “Science” or “Arts” and “A”

  • We will click on Cell D4 again
  • We will double-click on the fill handle (the small plus sign at the bottom right of Cell D4) and drag down to copy the formula into the other cells

Figure 4: Result of If Cell is “Science” or “Arts” and “A”

Explanation

=IF(AND(OR(B4="Science",B4="Arts"),C4="A"),"Qualified","Unsuitable")

The OR function checks Cell B4 if it has either science or arts as its value. The AND function checks if Cell C4 has the value, “A.” The IF function returns the result as Qualified or Unsuitable if the criteria are met.

Note

  • If we chose to only leave the inverted commas and remove “Unsuitable” from the formula, we will have empty cells in the place of Unsuitable as the result.
  • If we remove the False value (UNSUITABLE) including the inverted commas, we will have FALSE in the place of Unsuitable as the result.

Instant Connection to an Expert through our Excelchat Service

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

Did this post not answer your question? Get a solution from connecting with the expert.

Another blog reader asked this question today on Excelchat:
Here are some problems that our users have asked and received explanations on

I would like the VBA excel code syntax for this logic: 'For X = 3 to 816 - Loop rows 3 thru the last row (816) ' Z = 0 - Reset "Z" (indent counter) ' For Y = 2 to 8 - Loop thru columns "B" thru "H" on row "X" ' Z = Z+1 - Indent counter ' ' If Cell(X,Y) is NOT blank - The cell has content in it ' 'VBA function - Move cell content from Cell (X, Y) to Cell (X, 1) ' 'VBA function - Indent the content in cell (X, 1) 'Z' times ' Exit - "Y" loop '(columns) and move to next row ' End IF ' Next 'Y ' Next 'X
Solved by S. H. in 20 mins
I need a formula that if: - X is 160 to 147, Y is 82 to 74 and Z is 10 or less (It shows XL) - L is 146 to 140, Y is 73 to 71 and Z is 10 or less (It shows L) - M is 139 to 127, Y is 70 to 61 and Z is 10 or less (It shows M) - S is 126 or less, Y is 60 or less and Z is 9 or less (It shows S)
Solved by X. F. in 17 mins
I would like the VBA code for the following programming logic (AND the syntax for the 2 functions) For X = 3 to 816 - Loop rows 4 thru the last row (816) Z = 0 - Reset "Z" (indent counter) at beginning each new row For Y = 2 to 8 - Loop thru columns "B" thru "H" on row "X" Z = Z+1 - Increment the 'Z' counter (tracking the # of indents) If Cell(X,Y) is NOT blank - The cell has content in it Need VBA function - Move the cell content from it's current Cell (X, Y) to Cell (X, 1) Need VBA function - Indent the content that was moved into cell (X, 1), 'Z' times Exit "Y" loop - (columns loop) and go to the next row. End IF Next Y - Next column Next X - Next row
Solved by I. W. in 27 mins

Leave a Comment

avatar