Search code examples
if-statementgoogle-sheetsgs-conditional-formatting

Determine when a cell is blank


At work, I needed that if the value of a cell is equal to the cell next to it, then the background color changes to red, but it is doing it for blank cells, so it may be confusing for others.

Is there a way to avoid blank cells?

I have this formula:

=IF($D2=$C2,TRUE)

then background color changes to red (not sure if the correct formula, but it worked at the beginning, I am doing this in the Conditional Format Rules in Google Sheets).


Solution

  • I used this:

    =IF($D1=$C1,IF(ISBLANK($D1),FALSE,TRUE))
    

    I set the range to be C1:D1000. Your formula was putting the formatted color on the row above the data being checked. This formula checks if they are equal. Then if so it checks if one is blank. You don't have to check if they are both blank, the formula already knows that they are equal. So then if they are equal, return false, otherwise return true.