How to Use Conditional Formatting in Excel
In this article
Conditional formatting in Excel lets you automatically apply formatting—like colors, icons, or data bars—to cells based on their values or rules you set. It helps you spot trends, outliers, or deadlines at a glance, without manually changing cell styles. You only need a spreadsheet with data (numbers, dates, or text) and Excel 2010 or later (the steps are nearly identical in Excel for Microsoft 365, Excel 2021, 2019, and 2016). This guide walks you through the most common uses: highlighting cells, using color scales, and creating custom rules.
What You'll Need
- A computer with Microsoft Excel installed (Windows or Mac). The steps below work for both, but some menu labels may differ slightly by version.
- A worksheet with data you want to format—at least a few cells with numbers or dates.
- Basic familiarity with selecting cells and using the ribbon at the top of Excel.
Step-by-Step
Highlight Cells Based on a Rule (e.g., Greater Than)
- Open your Excel workbook and go to the worksheet containing the data you want to format.
- Select the range of cells you want to apply conditional formatting to. For example, if you have sales numbers in cells B2:B20, click and drag from B2 to B20. You can also click the column letter to select the whole column, but be careful—that will format every cell in that column, even empty ones.
- On the Home tab, in the Styles group, click Conditional Formatting. A dropdown menu appears.
- Hover over Highlight Cells Rules and choose a rule type, such as Greater Than, Less Than, Between, or Equal To. For this example, pick Greater Than.
- A dialog box opens. In the left field, type the threshold value. For instance, if you want to highlight sales over $500, type
500. - In the right dropdown, choose a formatting style. The default is Light Red Fill with Dark Red Text, but you can also pick Green Fill with Dark Green Text, Yellow Fill with Dark Yellow Text, or Custom Format to set your own font, border, or fill color.
- Click OK. The cells that meet the condition are now formatted.
Apply a Color Scale (e.g., Heat Map)
- Select the range of cells you want to format (for example, test scores in C2:C50).
- Go to the Home tab, click Conditional Formatting, and hover over Color Scales.
- Choose a preset, like Green-Yellow-Red Color Scale (low values are red, middle yellow, high green) or Blue-White-Red. Excel automatically assigns colors based on the value’s position between the minimum and maximum in the selected range.
- Click the preset to apply it. The colors update instantly.
- To customize the colors or the minimum/maximum thresholds, click Manage Rules at the bottom of the Conditional Formatting menu, select the rule, and click Edit Rule. You can change the colors and set specific numbers for the minimum, midpoint, and maximum.
Use Data Bars (In-Cell Bar Charts)
- Select the cells you want to show as bars (e.g., project completion percentages in D2:D10).
- On the Home tab, click Conditional Formatting and hover over Data Bars.
- Choose a fill style, such as Blue Data Bar or Gradient Fill. The bars appear inside the cells, proportional to the value relative to the highest value in the range.
- If you want the bars to be shorter or longer, edit the rule: go to Conditional Formatting > Manage Rules, select the rule, and click Edit Rule. You can set the minimum and maximum values (e.g., 0% to 100%) so the bars reflect a fixed scale rather than the range’s min/max.
Create a Custom Rule with a Formula
- Select the range you want to format (e.g., A2:A20 where you have dates).
- Click Conditional Formatting and choose New Rule.
- In the dialog, select Use a formula to determine which cells to format.
- In the formula box, enter a formula that returns TRUE for cells you want to format. For example, to highlight dates that are past due (before today), use
=A2<TODAY()(assuming A2 is the first cell in your selection). Important: the formula must be relative to the active cell in the selection—Excel uses the active cell (usually the first cell) as the reference point. If your selection starts at A2, the formula should reference A2. - Click the Format button, choose a fill color or font style, then click OK.
- Click OK again to apply the rule.
Manage and Clear Rules
- To see all rules applied to a range, select the range, go to Conditional Formatting > Manage Rules. The dialog shows each rule, its range, and the format.
- To remove a rule, select it and click Delete Rule. To remove all rules from the sheet, click Clear Rules and choose Clear Rules from Entire Sheet.
- To change the order of rules (Excel applies the first rule that matches, so order matters), use the up/down arrows in the Manage Rules dialog.
Common Mistakes
- Applying to the wrong range: If you select a single cell before adding a rule, Excel may apply it to that cell only. Always select the entire range you want to format before creating the rule.
- Using absolute references in formulas: In custom formula rules, you must use relative references (like A2, not $A$2) so the rule applies to each cell in the range. If you use absolute references, every cell will be compared to the same fixed cell, which is rarely what you want.
- Rule order conflicts: If you have multiple rules on the same range, the first rule in the list that evaluates to TRUE wins. For example, if you have a rule that highlights all cells greater than 100 in red and another that highlights cells greater than 200 in green, the red rule will apply to cells 200+ because it comes first. Use the up/down arrows to change the order.
- Forgetting to update the range when adding new data: Conditional formatting rules are tied to the range you selected. If you add new rows below the range, they won’t be formatted unless you expand the range in the rule (or convert your data to an Excel Table, which auto-expands).
Tips
- Use Stop If True for rules that should override others. In the Manage Rules dialog, check the “Stop If True” box for a rule to prevent later rules from applying to the same cells.
- Combine conditional formatting with Excel Tables (Ctrl+T) so that formatting automatically applies to new rows added to the table.
- Use the Format Painter (Home tab) to copy conditional formatting from one range to another: select the formatted cells, click Format Painter, then select the target range.
- For text-based rules, use “Text that Contains” under Highlight Cells Rules to highlight cells containing specific words or characters.
- To highlight entire rows based on a condition (e.g., all rows where the status is “Overdue”), use a custom formula rule that references the row’s key cell with a mixed reference (e.g., =$A2="Overdue") and apply it to the whole row range (e.g., A2:F20).
- Use color scales sparingly—too many colors can make a sheet hard to read. Stick to one or two formatting types per sheet.
Troubleshooting
If your conditional formatting doesn’t appear or behaves unexpectedly, try these checks in order.
- Check the rule range: Select the cells and open Manage Rules. Verify the range shown under “Applies to” covers the cells you want. If not, edit the range or reapply the rule.
- Verify the rule logic: For custom formulas, test the formula in a blank cell to see if it returns TRUE for a sample cell. For example, if your rule is =A2>100, type =A2>100 in a cell and see if it says TRUE.
- Check for conflicting rules: If a cell has multiple rules, the first TRUE rule wins. In Manage Rules, look at the order and adjust it, or enable “Stop If True” on the rule you want to take precedence.
- Make sure the cell values are numbers, not text: If your data is stored as text (e.g., “500” with an apostrophe), numeric comparisons like “Greater Than” won’t work. Convert text to numbers by selecting the column, clicking the warning icon, and choosing “Convert to Number.”
- Check if the sheet is protected: Conditional formatting may not update if the worksheet is protected and the cells are locked. Unprotect the sheet (Review tab > Unprotect Sheet) and try again.
- If nothing works, clear all rules: Go to Conditional Formatting > Clear Rules > Clear Rules from Entire Sheet, then reapply the rule from scratch. This often fixes hidden corruption.
Frequently Asked Questions
Can I use conditional formatting to highlight duplicate values?
Yes. Select the range, go to Conditional Formatting > Highlight Cells Rules > Duplicate Values. Choose a format and click OK. Excel highlights duplicate values in the selected range.
How do I format an entire row based on a cell value?
Use a custom formula rule. Select the entire row range (e.g., A2:F20), create a new rule with a formula like =$A2="Overdue" (adjust the column letter to your key column). The dollar sign locks the column, so the rule applies to the whole row.
Why is my conditional formatting not working when I sort or filter?
Conditional formatting is based on cell values, so it should still work after sorting or filtering. However, if you used a formula with relative references, the rule may shift if you move cells. To avoid issues, use absolute references for the column (like $A2) when you want the row to move with the data.
Can I copy conditional formatting to another sheet?
Yes. Select the formatted cells, press Ctrl+C (copy), go to the target location, right-click, and choose “Paste Special” > “Formats” (or use the Format Painter). This copies the conditional formatting rules, but they will reference the new sheet’s cells.
How do I remove conditional formatting but keep the data?
Select the range, go to Conditional Formatting > Clear Rules > Clear Rules from Selected Cells. Your data remains unchanged; only the formatting is removed.
Does conditional formatting slow down Excel?
It can, especially if you have many rules or apply them to entire columns (e.g., A:A). To keep performance good, apply rules only to the actual data range, and avoid using volatile functions like TODAY() in formulas if you have thousands of rules.