Excel: How to Colour a Cell Based on Its Value
In this article
You can colour a cell based on its value in Excel by using Conditional Formatting. The quickest route is to select your cells, go to Home > Conditional Formatting > Highlight Cells Rules, and pick a rule such as Greater Than, Less Than, Between, or Equal To. Excel then fills the cell automatically whenever the value meets the rule, and updates the colour as soon as the number changes. No macros are required, and the formatting stays with the cell when you sort or filter.
This guide covers the built-in rules, custom formulas for more complex logic, how to edit or remove rules, and the mistakes that most often stop conditional formatting from working. Menu labels can differ slightly between Excel for Windows, Excel for Mac, Excel on the web, and different versions, so if a label is not exactly where described, look for the closest match in the same area.
What You'll Need
- Excel for Windows, Excel for Mac, or Excel for the web (the steps below use the desktop ribbon; the web version has the same Conditional Formatting menu under Home).
- A worksheet with values already entered — text, numbers, or dates all work.
- Your data ideally arranged in a clean range or table, with a single header row and no blank rows in the middle, so rules apply predictably.
Step-by-Step
- Select the cells you want to colour. Drag across the range, or click the first cell and hold Shift while clicking the last. If you want the rule to apply to a whole column, click the column letter. Avoid selecting the header row unless you want the header coloured too.
- Open the Conditional Formatting menu. On the Home tab, in the Styles group, click Conditional Formatting. A drop-down opens with several categories.
- Choose a built-in rule that matches your logic. Hover over Highlight Cells Rules and pick the comparison you need: Greater Than, Less Than, Between, Equal To, Text that Contains, A Date Occurring, Duplicate Values, and so on.
- Enter the threshold value. A small dialog appears. Type the number, text, or date the cells should be compared against. For Between, enter both the minimum and maximum.
- Pick a format from the right-hand drop-down. The list offers presets such as Light Red Fill with Dark Red Text or Green Fill with Dark Green Text. Choose Custom Format if you want a specific fill colour, font colour, bold, or border. In the Format Cells dialog, the Fill tab sets the background colour.
- Click OK. The selected cells are coloured immediately wherever the condition is true. Change a value in one of those cells and the colour updates on its own.
- For colour scales or data bars, use a different category. With the range still selected, go to Conditional Formatting > Color Scales and pick a two-colour or three-colour scale. This shades cells on a gradient from low to high, which is useful for spotting outliers at a glance. Data Bars and Icon Sets live in the same menu and work the same way: select the range, choose the style, and Excel applies it.
- For logic the presets cannot express, use a formula rule. Select the range, then choose Conditional Formatting > New Rule > Use a formula to determine which cells to format. In the formula box, write a formula that returns TRUE or FALSE, starting with an equals sign and referring to the top-left cell of the selection (for example
=A2>100when A2 is the active cell). Do not put dollar signs around the row number unless you want the rule locked to one row. Click Format, set the fill, and click OK twice. - Review and adjust existing rules. Select the range and go to Conditional Formatting > Manage Rules. The dialog lists every rule affecting the selection. From here you can edit a rule, change the range it applies to, tick Stop If True to prevent lower rules from overriding it, or delete it.
- Remove formatting when you no longer need it. Select the cells and choose Conditional Formatting > Clear Rules > Clear Rules from Selected Cells. This removes the rule but leaves any manual fill colour you applied by hand.
Common Mistakes
- Selecting the wrong starting cell for a formula rule. Excel anchors the formula to the active cell in your selection. If you select A2:A100 but the active cell is A1, the rule evaluates the wrong rows and colours appear offset by one row.
- Using relative references where absolute ones are needed. A rule like
=A2>$B$2compares every row to a fixed threshold in B2. Writing=A2>B2instead compares each row to a different cell, which is usually not what you want. - Numbers stored as text. If a value looks like a number but is left-aligned in the cell, it may be text. Numeric rules such as Greater Than will not fire on text. Convert it with Data > Text to Columns or by re-entering the value.
- Expecting conditional formatting to copy with the cell. If you copy a cell and paste only the value, the rule may not travel. Use Format Painter or copy the whole cell to carry the formatting across.
- Confusing manual fill with conditional fill. A cell can have both. If a rule seems not to work, check whether a manual fill is sitting on top; clear the manual fill first.
- Overlapping rules fighting each other. When two rules apply to the same cell, the one higher in the Manage Rules list wins. Use Stop If True to make the order explicit.
Tips
- Convert your range to a table with Ctrl+T (Cmd+T on Mac). Rules then extend automatically as you add rows.
- Use Color Scales for a quick visual heat map of a column of numbers — no thresholds to choose.
- Keep rule formulas short and test them in a spare cell first; if the formula returns FALSE there, the formatting rule will not fire either.
- Name your rules clearly if you share the workbook. In Manage Rules you can see the range each rule applies to, which makes auditing easier.
- Conditional formatting survives sorting and filtering, so it is safe to use on data you reorder regularly.
Troubleshooting
The colour does not appear at all. Check that the rule's range actually covers the cells you are looking at (Manage Rules shows the range). Confirm the values are the type the rule expects — numbers, not text. Then clear any manual fill colour underneath.
The wrong cells are coloured. This is almost always a relative-reference problem in a formula rule. Select the range again, open Manage Rules, edit the rule, and make sure the formula refers to the top-left cell of the selection with the correct row and column references.
The colour disappears after editing a value. The rule may be scoped to a fixed range that no longer includes the edited row, or the new value may no longer meet the condition. Re-select the range and reapply the rule if needed.
Rules look different on another computer. Conditional formatting colours are stored in the workbook, but the exact shade can render slightly differently depending on the display and Excel version. The logic itself does not change.
You cannot find a rule you added. Select a cell the rule should affect and open Manage Rules — it lists rules for the current selection. If nothing appears, the rule was applied to a different range.
Frequently Asked Questions
Can I colour a cell based on another cell's value?
Yes. Use a formula rule and point the formula at the other cell, for example =$B2>100 applied to the range you want coloured. Lock the column with a dollar sign so every cell in the range checks the same column.
Does conditional formatting work on text as well as numbers?
Yes. Text that Contains, Equal To, and formula rules all work with text. Formula rules are the most flexible because they can combine text and number checks.
Will the colours survive if I save as PDF or print?
Yes, conditional formatting is included when you print or export to PDF, provided the print area covers the formatted cells.
Can I apply more than one rule to the same cell?
Yes, and Excel evaluates them in the order shown in Manage Rules. Use Stop If True to control which rule takes priority.
Why does my rule colour the header row too?
Because the header is inside the selected range. Either exclude the header when selecting, or add a formula rule that checks the row number, or apply the rule only to the data rows.
Is conditional formatting available in Excel on the web?
Yes, the core options — Highlight Cells Rules, Color Scales, Data Bars, and formula-based rules — are available under Home > Conditional Formatting in Excel for the web, though some advanced formatting options may be limited compared with the desktop app.