Conditional Formatting in Excel: A Practical Guide
Conditional Formatting in Excel: A Practical Guide
Conditional Formatting automatically changes a cell's colour, font, or icon based on rules you set, without you needing to manually format anything yourself. Excel comes with built-in presets for common cases like highlighting duplicates or colour-scaling a range of numbers, but the real power is in the formula-based option, which lets you build a rule around almost any condition you can write as a formula.
For longer than I'd like to admit, I built monthly sales heatmaps by eye — manually shading cells red, yellow, or green based on how each region's numbers compared to target, one cell at a time, every single month. It looked fine in the final report, but it took ages and I had to redo the whole thing from scratch whenever the numbers changed even slightly. A colleague eventually watched me doing this and asked, genuinely confused, why I wasn't just using Conditional Formatting with a formula rule. I didn't really have a good answer beyond "I've just always done it this way," which is a phrase I've come to be a bit suspicious of whenever I catch myself saying it.
How do I apply basic Conditional Formatting?
- Select the range you want to format
- Go to Home > Conditional Formatting
- Choose one of the built-in rule types — Highlight Cells Rules (like "Greater Than" or "Duplicate Values"), Top/Bottom Rules, Data Bars, Colour Scales, or Icon Sets
- Set the condition and choose a formatting style
- Click OK
For a quick example, highlighting every cell over $1,000: Home > Conditional Formatting > Highlight Cells Rules > Greater Than, then type 1000 and pick a colour.
What's the difference between the built-in rules and a formula-based rule?
The built-in presets cover common, simple scenarios well — highlighting values above or below a threshold, colour-scaling a range, or flagging exact duplicates. A formula-based rule lets you define any condition yourself, including ones that reference other cells, other columns, or combine multiple conditions together, which the built-in presets simply can't do.
To use a formula-based rule:
- Select your range
- Home > Conditional Formatting > New Rule
- Choose "Use a formula to determine which cells to format"
- Type a formula that evaluates to TRUE or FALSE for the top-left cell of your selection
- Click Format, choose your styling, and click OK
How do I highlight an entire row based on one column's value?
This is one of the most useful formula-based tricks, and it's not obvious from the built-in presets at all. Say you want to highlight the entire row whenever the "Status" column (column E) says "Overdue."
- Select the full data range, starting from column A
- New Rule > Use a formula
- Enter:
=$E2="Overdue" - Format with your chosen highlight colour
- Apply
The key detail people miss here is the dollar sign placement. Locking the column with $E2 (not $E$2) means every cell in the row checks column E specifically, while still allowing the row number to adjust as the rule applies down the whole selection. Getting this wrong is the single most common reason formula-based Conditional Formatting doesn't behave as expected.
Can I use COUNTIF inside a Conditional Formatting rule?
Yes, and this is a genuinely handy combination. If you've read my post on "SUMIF, COUNTIF and SUMIFS", you'll remember COUNTIF as a way to spot duplicates using a formula. You can turn that same logic into a visible highlight instead of a helper column full of numbers.
Highlighting duplicate client names directly, without a separate count column:
=COUNTIF($A$2:$A$200, A2)>1
This checks whether the current value appears more than once anywhere in the full range, and highlights it if so — no helper column needed at all, since Conditional Formatting handles the counting invisibly behind the scenes.
Why isn't my Conditional Formatting rule applying to the cells I expect?
A handful of common causes:
- Wrong range selected before creating the rule. The rule only applies to whatever was selected at the time you created it — check Home > Conditional Formatting > Manage Rules to see and adjust the "Applies to" range.
- Absolute vs relative reference mistakes, as covered above with the row-highlighting example. Getting
$placement wrong is the most common formula-based issue. - Multiple overlapping rules, where one rule is silently overriding another. Manage Rules shows the order rules are evaluated in, and you can reorder or tick "Stop If True" to control this.
- The formula references the wrong starting cell. Your formula should always reference the top-left cell of your selected range, not a random cell within it.
FAQ
Can I have more than one Conditional Formatting rule on the same range? Yes, and Excel evaluates them in the order shown in Manage Rules, applying each one that's true unless "Stop If True" is ticked on an earlier rule.
Does Conditional Formatting slow down large spreadsheets? It can, particularly with formula-based rules applied across very large ranges, since Excel needs to re-evaluate the formula for every cell whenever the sheet recalculates. For everyday spreadsheet sizes, it's rarely noticeable.
Can I copy Conditional Formatting to another range like regular formatting? Yes — use the Format Painter (the paintbrush icon), or copy the cells and use Paste Special with "Formats" selected, and the rule carries across to the new range.
Why did my highlighted duplicates disappear after I sorted the data? This usually means the rule's range reference wasn't set up with the right mix of absolute and relative references, so sorting shifted which cells the rule is actually checking. Rebuilding the rule with correctly locked references (as shown in the row-highlighting example) fixes this.
Is there a limit to how many Conditional Formatting rules I can have in one workbook? There's no meaningful practical limit for typical use, though having dozens of overlapping rules across a large workbook can make it noticeably slower and much harder to maintain. It's worth periodically checking Manage Rules and removing anything no longer needed.
Why does my duplicate-highlighting rule miss entries that look identical? This is almost always the same hidden-space or invisible-character issue covered in my post on "Cleaning Messy Data". Conditional Formatting's COUNTIF-based duplicate check is just as sensitive to trailing spaces as a regular formula, so cleaning the data first will fix highlighting that seems to be missing obvious repeats.
Comments
Post a Comment