Conditional Formatting in Excel: highlight cells and rows by condition
Conditional Formatting colors cells automatically based on their values: big amounts, overdue payments, duplicates, top and bottom results.
Example
Formula:
=$D2="Overdue"→ result: TRUE
What Conditional Formatting is and where to find it
Conditional Formatting changes a cell’s format (fill, font, border) based on its value. When the value changes, the color updates by itself — no manual coloring. Where: Home → Conditional Formatting. From the keyboard: Alt → H → L opens the menu, then H (Highlight Cells Rules), T (Top/Bottom Rules), D (Data Bars), S (Color Scales), I (Icon Sets), N (New Rule), R (Manage Rules). The workflow is always the same: select the range first, then pick a rule.
Built-in rules: Highlight Cells and Top/Bottom
Highlight Cells Rules are the simplest conditions: • Greater Than / Less Than / Between — e.g. amounts over 1,000,000. • Equal To — an exact value. • Text that Contains — the text includes a certain word. • A Date Occurring — yesterday, today, last week, this month. • Duplicate Values — duplicate or unique values. Top/Bottom Rules show the best and worst results: Top 10 Items, Top 10%, Bottom 10 Items, Above Average, Below Average. You can change the 10 in the dialog to any number, e.g. Top 3.
Data Bars, Color Scales and Icon Sets
These three are for visual analysis of numbers: • Data Bars — a bar inside the cell whose length matches the value. Great for comparing sales, stock or completion rates. • Color Scales — a color gradient: low values red, high values green (or the other way round). This is how you build a heatmap. • Icon Sets — arrows, traffic lights, flags. By default the thresholds are percentages (67% and 33%); use Manage Rules → Edit Rule and set Type to Number for exact values. Tip: to hide the number behind a data bar, tick “Show Bar Only” in the Edit Rule dialog.
Formula rules: highlight an entire row
The most powerful option is your own formula. For example, to color the whole row red when the status is “Overdue”: 1. Select A2:D100 (without the header, starting at A2). 2. Home → Conditional Formatting → New Rule → “Use a formula to determine which cells to format”. 3. Formula: =$D2="Overdue" 4. Format… → Fill → red → OK. Rows where the formula returns TRUE get colored. In the example above, for row 2 =$D2="Overdue" → TRUE. The $ locks column D, so every cell in A, B, C and D checks column D and the whole row is formatted. The row number (2) has no $, so Excel shifts it to 3, 4, 5… for each row.
Practical rule formulas
• Overdue and not paid: =AND($B2<TODAY(),$D2<>"Paid") • Due within the next 7 days: =AND($B2>=TODAY(),$B2<=TODAY()+7) • Duplicate value (by formula): =COUNTIF($A$2:$A$100,$A2)>1 • Banded rows (“zebra”): =MOD(ROW(),2)=0 • Weekends (Saturday, Sunday): =WEEKDAY($B2,2)>5 • Threshold from a cell: =$C2>$G$1 — change the number in G1 and the highlighting follows.
Managing rules
Home → Conditional Formatting → Manage Rules, or Alt → H → L → R. In this dialog: • Set “Show formatting rules for” to This Worksheet to see every rule on the sheet. • Applies to — the range the rule covers. Extend it here when you add rows. • Use the arrows to change the order: higher rules take priority. If two rules change the same property (say, the fill color), the upper one wins. • Stop If True — when a rule is met, rules below it are not checked for that cell. For example, to hide icons in blank cells, put a no-format rule above the Icon Set and tick Stop If True. To remove rules: Conditional Formatting → Clear Rules → Clear Rules from Selected Cells or from Entire Sheet.
Common mistakes
• Wrong $: =$D$2="Overdue" makes every row look at row 2 only, so either all rows are colored or none. Use $D2. • Formula not written for the active cell: if your selection starts at A1 but the formula says $D2, the highlighting is shifted one row down. Always write the formula for the first (top-left) cell of the selection. • Numbers stored as text: a “Greater Than 100000” rule ignores text numbers. Convert the column to numbers. • A space in the criteria text: “Overdue ” ≠ “Overdue”. Clean the data with TRIM. • Copy-pasting multiplies rules and slows the file down. Delete duplicates in Manage Rules or merge the ranges into one rule.
Pro tips
• Turn the data into a table (Ctrl+T) so rules extend to new rows automatically. • Keep thresholds in their own cells ($G$1) so a manager can change the limit without touching the formula. • To pull out the colored rows, use Filter → Filter by Color. • Copy formatting to another range with the Format Painter (Alt → H → F → P). • Use color sparingly: 2–3 meaningful colors (red = problem, green = good) make a sheet easy to read; a rainbow table just distracts.
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.