Often you may want to apply conditional formatting to two cells in Excel if their values are not equal.
The following example shows exactly how to do so.
Example: Conditional Formatting if Two Cells Are Not Equal
Suppose we have the following lists in Excel that contain the names of 10 students each:
Suppose we would like to highlight the rows where the two names are not equal between the classes.
To do so, highlight the values in the range A2:B11, then click the Conditional Formatting icon on the Home tab, then click New Rule:
In the new window that appears, click Use a formula to determine which cells to format, then type in the following formula into the box:
=$A2 <> $B2
Then click the Format button and choose a fill color to use, then click OK:
Each row where the names are not equal will automatically be highlighted:
Note that this formula is case-insensitive. This means if we have “john” in one column and “John” in the other, the formula will assume these values are equal.
However, you can use the following formula to apply a case-sensitive search:
=NOT(EXACT($A2,$B2))
This means if we have “john” in one column and “John” in the other, the formula will assume these values are not equal and will apply conditional formatting to them.
Additional Resources
The following tutorials explain how to perform other common tasks in Excel:
Excel: Apply Conditional Formatting if Cell Contains Text
Excel: Apply Conditional Formatting with Multiple Conditions
Excel: Apply Conditional Formatting if Between Two Values