Exceljet

Quick, clean, and to the point

If cell equals

Excel formula: If cell equals
Generic formula 
=IF(A1="red",true result,false result)
Summary 

To take one action when a cell is equal to a certain value, and another when not equal, you can use the IF function. In the example shown, the formula in cell D6 is:

=IF(B6="red","x","")
Explanation 

If you want to do something specific when a cell equals a certain value, you can use the IF function to test the value, then do something if the result is TRUE, and (optionally) do something else if the result of the test is FALSE.

In the example shown, we want to mark rows where the color is red with an "x". In other words, we want to test cells in column B, and take a specific action when they equal the word "red". The formula in cell D6 is:

=IF(B6="red","x","")

In this formula, the logical test is this bit:

B6="red"

This will return TRUE if the value in B6 is "red" and FALSE if not. Since we want to mark or flag red items, we only need to take action when the result of the test is TRUE. In this case, we are simply adding an "x" to column D if when the color is red. If the color is not red (or blank, etc.), we simply return an empty string (""), which displays as nothing.

Note: if an empty string ("") is not provided for value_if_false, the formula will return FALSE when the color is not red or green.

Increase price if color is red

Of course, you could do something more complicated as well. For example, let's say you want to increase the price of red items only by 15%.

In that case, you could use this formula in column E to calculate a new price:

=IF(B6="red",C6*1.15,C6)

IF function example - increase price if color is red

The test is the same as before (B6="red"). If the result is TRUE, we multiply the original price by 1.15 (increase by 15%). If the result of the test is FALSE, we simply use the original price as-is.

Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 200+ Excel Shortcuts

Get over 200 Excel shortcuts for Windows and Mac in one handy PDF.