Go Back

How to Use “IF CELL IS THIS OR THAT”

We can use a formula that combines the IF and OR functions to return a value if a cell contains either of two values. The formula returns a TRUE or FALSE or whatever we have specified. The steps below will walk through the process.

Figure 1: Result for IF A CELL CONTAINS THIS OR THAT

General Formula

=IF(OR(A4="this",A4="that"),"YES","")

Formula

=IF(OR(A4="Vegas",A4="Dallas"),"YES","")

Setting up the Data

We will use the data below that show the yearly sales for a product in different states at different times by a company. We intend to check each cell if it contains Vegas or Dallas.

  • We will input the states in Cell A4 to Cell A13
  • We will input the yearly sales in Cell B4 to Cell B13
  • Cell C4 to Cell C13 will contain the results that are returned by the formula. “YES” is returned if the cell contains VEGAS or DALLAS and an empty cell is returned if the cell does not contain VEGAS or DALLAS

Figure 2: Setting up the Data for IF A CELL CONTAINS VEGAS or DALLAS

If a Cell Contains Vegas OR Dallas

  • We will click on Cell C4
  • We will insert the formula below into Cell C4

=IF(OR(A4="Vegas",A4="Dallas"),"YES","")

 

  • We will press the enter key

 

Figure 3: Result for Cell C4 IF A CELL CONTAINS VEGAS or DALLAS

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

Figure 4: Result for IF A CELL CONTAINS VEGAS or DALLAS

Explanation

=IF(OR(A4="Vegas",A4="Dallas"),"YES","")

In this formula, the OR function checks the specified cell if it contains either VEGAS or DALLAS. The IF Function returns TRUE or FALSE based on what is returned by the OR function. However, we have specified that the IF FUNCTION returns YES as TRUE and an EMPTY CELL (“”) as FALSE.

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

How do I write this formula - "If cell A1 is less then 30 = 0 OR If cell A1 is between 30 & 32 = 1 OR If Cell A1 is between 33 & 35 = 2 OR If cell A1 is between 36 & 38 = 3 OR If cell A1 is greater then 38 = 4"
Solved by A. W. in 21 mins
Is there a way to conditionally format one cell so that if there is input in a checkbox or another cell that the first cell will be empty even though there is a standard formula returning a value to be placed in that cell? A value in this one cell is only pertinent IF a value in another cell is True, checked, or Yes, something like that. And we want the cell to be blank if the other cell is False, not checked, or No.
Solved by A. A. in 15 mins
Is there a way to conditionally format one cell so that if there is input in a checkbox or another cell that the first cell will be empty even though there is a standard formula returning a value to be placed in that cell? A value in this one cell is only pertinent IF a value in another cell is True, checked, or Yes, something like that. And we want the cell to be blank if the other cell is False, not checked, or No.
Solved by G. L. in 12 mins

Leave a Comment

avatar