As is often the case in Excel, there are multiple ways to approach this problem.

The simplest way is to use the OR function with the LEFT function to create the required logical test.

Another option is to use the COUNTIF function.

Excel formula: If cell is this OR that

Both approaches are explained below.

Note: this formula is more advanced because we need to test for “cell begins with”.

For a more basic example of “cell equals this or that"see this pageorthis video.

Excel formula: If cell is x or y and z

OR + LEFT

TheOR functionreturns TRUE if any argument is TRUE.

It works like a range in Excel, except the values in an array constant are hard coded.

Putting this all altogether, we can use the formula above inside the IF function as the logical test.

Excel formula: If cell contains

However, you’ve got the option to also use a normal range on the worksheet.

To test more than one character, adjust num_chars as needed.

If no cells meet the criteria, COUNTIF returns zero.

Excel formula: If cell is not blank

The first count (0) is the count for cells that begin with “x”.

The second count (0) is for cells that begin with “y”.

The third count (1) is for cells that begin with “z”.

Excel formula: Cell contains one of many things

To check this, we add up all items using the SUM function.

Excel will automatically evaluate any number as TRUE and zero (0) as FALSE.

However, if the result from SUMis zero, IF will return an empty string ("").

Excel formula: If cell contains this or that

OR returns TRUEif any condition is TRUE.

If all conditions are FALSE, the OR function returns FALSE.

For example, =LEFT(“apple”,3) returns “app”.

Excel OR function

More than one condition can be tested by nesting IF functions.

Excel LEFT function

Excel IF function

Excel COUNTIF function

Article image

Article image