Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users

Dashboard
Notifications
Mark all as read
Q&A

Conditionally format a pair of columns

+2
−2

A user of Web Applications asked "How should I fix the formula?" with reference to:

=IF($K4<2,$K4)

applied as a Conditional Formatting [CF] formula to J4:J8, where the desired (green fill) format was to apply to values under 2 in K4:K8. I have modified the requirement to extend the formatting to 'K' as well as 'J', so the Applies to range to J4:K8.

These formulae in the image below were working as expected:

CF rules

How can the desired outcome be achieved?

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comments

1 answer

+2
−0

First, such formatting is conditional, so there is no need for the IF functions here (nor, normally, in general for Conditional Formatting [CF]). Formatting is triggered when the response to a formula is TRUE (or equivalent). So, for red fill:

 =$K4>5

is sufficient, as is:

 =$K4>=2

for yellow fill. (Or, =$K4>1 if the 'K' values are always integers.)

Since say 6 is greater than both 5 and 2 either a range for validity should be set rather than just a minimum (elaborating the formula) or, as here, the red fill rule should be above the yellow fill rule in the Conditional formatting rules list.

Second, a quick fix assuming that all J:K pairs are to be coloured, is to forego CF for green. Instead apply 'standard' (green) fill to the entire range. CF fill overrides 'standard' fill.

Third, if not the quick fix, then a formula for green fill such as:

=$K4<2

Finally, the formula attempted does not work for 0, while the others do what is required, because of how CF interprets values. CF deems 0 to be FALSE so the condition is not satisfied and therefore the associated formatting is not applied. Whereas, excluding 0, the return of any number is deemed TRUE and the associated formatting triggered (as for the other rules).

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

Sign up to answer this question »