Notifications
Q&A

A Conditional Formatting formula rule expected to apply to all cells is only affecting some

+0
−0

A very recently asked Q on Web Applications has no answer yet (and, in my opinion, is so badly written may not receive an answer at all promptly). However it does seem (in my interpretation) to raise a very common issue with Conditional Formatting [CF] – with a very simple solution. The asker chose an Applies to range of C2:X2, a formula condition of:

=ISBLANK(B2) 

and formatting of White font with Black fill, then complained that since:

B2 is never empty

(other than at the bottom of the sheet) the resultant "fill" did:

not apply properly to all cells

An "image of the issue" shows (amongst a lot else) for Rows 2 and 3 a mix of populated and empty cells, some of each of which are formatted. Below the populated cells in the part of the range that is visible are represented by their column letter and the formatted cells with f:

| C | D | | f | Gf | H | I | J | | f | f | f | f | f | Qf | R | |

The pattern is that only cells immediately to the right of a blank cell appear conditionally formatted, regardless of whether or not themselves populated (and, apart from for C2, whether or not B2 is).

With an edit:

=IF(ISBLANK(B2), true, true) it works as expected

the intent can be deduced to be that all of C2:X2 should be conditionally formatted when B2 is not blank.

(i) Is Google Sheets Conditional Formatting applying improperly and (ii) what is required to achieve the objective?

Why should this post be closed?

0 comments

1 answer

+0
−0

(i) No.
(ii) A formula rule of:

=isblank($B2)

i.e. merely anchoring the column ($).


The documentation does warn:

Absolute vs. relative references

Often, you will need to add dollar signs ($) in front of letters and numbers in formulas so that the formatting is applied using absolute references as opposed to relative references (A1 to B1, A2 to B2).

though perhaps is not as clear as it might be.

However, a specific example is also provided (though with an unfortunately positioned full stop):

  1. Write the rule for the first row. For example, if you want to make the whole row green if the value in column B is "Yes", write a formula like "=$B1="Yes"."

CF effectively steps through each cell within the range in turn and automatically adjusts relative references in a formula rule. In the question B2 is relative (it's not $B$2), so for C2 (the start of the range) the test is whether B2 is blank. B2 isn't blank ("is never empty") so C2 is formatted. However for D2 the cell 'one to its left' (relative) is populated, so the formatting not triggered for that cell. Hence the pattern mentioned in this Q.

Users have relatively little difficulty in appreciating that row reference numbers may be incremented automatically but seem to find a lot of difficulty in appreciating than relative column references may also be automatically incremented.

0 comments

Sign up to answer this question »