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
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

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?

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

0 comment threads

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).

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

0 comment threads

Sign up to answer this question »