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.

## Leave a Comment