How to use conditional formatting in Excel
Select the cells, then on the Home tab choose Conditional Formatting. Pick a built-in rule such as Highlight Cells Rules (Greater Than, Text that Contains, Duplicate Values), Top/Bottom Rules, Data Bars, Color Scales, or Icon Sets, and set the value or style in the dialog.
For a rule Excel does not list, go to Home > Conditional Formatting > New Rule, choose Use a formula to determine which cells to format, enter a formula that returns TRUE or FALSE for the first cell in the selection (for example =$B2<10), choose a format, and select OK. Manage, edit, or delete rules with Conditional Formatting > Manage Rules. On Excel for Windows you can also select the data and press Ctrl+Q (or click the Quick Analysis button) and use the Formatting tab.
These Home-tab rules apply in Excel for Microsoft 365, Excel for the web, and Excel 2024, 2021, 2019, and 2016. A formula rule should be written for the first cell in the selection, with $ on the column if the format should follow one cell across a whole row.
Apply conditional formatting
Highlight cells that meet a condition
- Select the range, table column, or cells you want to format. Include only the data you want the rule to test, not unrelated totals unless you intend to format those too.
- On the Home tab, select Conditional Formatting.
- Point to Highlight Cells Rules and choose a comparison such as Greater Than, Less Than, Between, Equal To, Text that Contains, A Date Occurring, or Duplicate Values.
- Enter the number, text, or cell reference to compare against, pick a format preset (or a custom format), and select OK.
- For highest or lowest values, use Top/Bottom Rules (Top 10 Items, Top 10%, Above Average, and the matching bottom or below-average options).
Use data bars, color scales, or icon sets
- Select the numeric cells.
- On the Home tab, select Conditional Formatting, then Data Bars, Color Scales, or Icon Sets, and click a style.
- Data bars make larger values into longer bars. Color scales shade cells along a two- or three-color gradient (typically higher, midpoint, and lower values). Icon sets assign an icon by threshold, for example a three-icon set at 67% and 33%.
- To tweak thresholds or hide the cell’s number and show only the bar or icon, go to Conditional Formatting > Manage Rules, select the rule, and choose Edit Rule.
Create a formula rule
- Select the cells that should receive the format. Remember which cell is the active cell (the first cell of the selection); the formula is written relative to that cell.
- Go to Home > Conditional Formatting > New Rule.
- Select Use a formula to determine which cells to format.
- Enter a formula that starts with
=and returns TRUE when the format should apply. Examples:=$B2<10highlights the row’s selected cells when column B is under 10;=AND($C2="West",$D2>1000)needs both conditions. Lock the column with$when the test should stay on one column as the format is applied across the row. - Select Format, choose font, border, or fill, then select OK twice.
Review, edit, or clear rules
- Go to Home > Conditional Formatting > Manage Rules. Set the list scope to Current Selection or This Worksheet if a rule does not appear.
- Select a rule to Edit Rule, change its range, or change its priority with the up and down arrows. Excel applies rules in order, and a later rule may override an earlier one if Stop If True is not used (desktop).
- To remove formatting, use Conditional Formatting > Clear Rules and choose Clear Rules from Selected Cells or Clear Rules from Entire Sheet. Clearing rules removes the conditional formats, not the cell values.
Quick Analysis on Excel for Windows
- Select the data. The Quick Analysis button appears at the lower-right of the selection; you can also press Ctrl+Q.
- Open the Formatting tab, preview the options, and click one. Microsoft notes that the available options depend on the selection: text-only selections show Text, Duplicate, Unique, Equal To, and Clear; numeric selections also offer Data Bars, Colors, Icon Sets, Greater, and Top 10%.
- Quick Analysis is a Windows convenience. On Excel for the web and Excel for Mac, use the Conditional Formatting menu on the Home tab instead.
Useful formula-rule examples
Write the formula for the first (active) cell in the selection, then let Excel apply it down the range.
- Highlight an entire row when a status is overdue: select
A2:F100with A2 active, use=$E2="Overdue". - Highlight unpaid amounts over a threshold in column C:
=$C2>500. - Highlight weekend dates in column A:
=WEEKDAY($A2,2)>5. - Highlight blanks in a required column:
=$B2="". - Alternate row shading with a formula (if you are not using a table’s banded rows):
=MOD(ROW(),2)=0.
If the rule does nothing, check that the formula returns TRUE/FALSE, that dollar signs lock the intended column, and that Manage Rules shows the correct range.
PivotTables and Excel for the web
Microsoft’s article states that conditional formatting generally works the same on a range, a table, or a PivotTable report, with extra limits on PivotTables: some formats (including unique or duplicate value rules) do not apply to fields in the Values area, and the format can stay in place when you filter or rearrange the PivotTable as long as the underlying fields remain. If a layout change drops a rule, reapply it from Manage Rules.
Excel for the web includes conditional formatting on the Home tab, but some advanced desktop options (certain rule types or Quick Analysis) may be missing. If a command is not in the web app, open the workbook in desktop Excel to edit the rule, then return to the web.
Troubleshooting
- The format does not appear. Confirm the rule’s range in Manage Rules, and that the condition is actually true for those cells. Text numbers (
"10"versus 10) and extra spaces often fail Greater Than or Equal To rules. - Only one cell formatted, or the wrong cells formatted. The formula was probably written for the wrong active cell, or a
$is missing or in the wrong place. Edit the rule and test it against the first cell of the range. - Rules conflict. Two rules can apply to the same cells. Change the order in Manage Rules, or clear the extra rule.
- Copied formatting went to the wrong place. Conditional formats copy with cells. Use Clear Rules from Selected Cells on the destination, or copy values only with Paste Special > Values.
- Merged cells or filtered rows look wrong. Unmerge where you can, and remember that a filter only hides rows — it does not change whether a rule is true.
Frequently asked questions
How do I apply conditional formatting based on another cell in Excel?
Use a formula rule. Select the cells to highlight, go to Home > Conditional Formatting > New Rule, choose Use a formula to determine which cells to format, and enter a formula that refers to the other cell or column, such as =$B2>=$H$1. Keep the column locked with $ if the same test should apply across each row, then set a format and select OK.
What is the difference between a color scale and a Highlight Cells rule?
A Highlight Cells rule (for example Greater Than or Text that Contains) applies one format when a condition is true. A color scale shades every selected number on a gradient between the lowest and highest values (or a midpoint), which is better for seeing distribution. Data bars and icon sets are the other two visual sets on the same Conditional Formatting menu.
How do I remove conditional formatting without deleting the data?
Select the cells (or the whole sheet) and choose Home > Conditional Formatting > Clear Rules, then Clear Rules from Selected Cells or Clear Rules from Entire Sheet. The values stay; only the rule-based formats are removed. You can also delete a single rule in Manage Rules.
Why is my formula rule not working?
The usual causes are a formula that does not return TRUE or FALSE, a reference written for the wrong starting cell, or a missing $ on a column you wanted locked. Open Manage Rules, confirm the Applies to range, and test the formula in an empty cell next to the first row of the range.
Can I use conditional formatting in Excel for the web?
Yes. Excel for the web is included in Microsoft’s applies-to list for this feature, and you can apply built-in rules from Home > Conditional Formatting. If a specific desktop option such as Quick Analysis or a less common rule type is missing, create or edit the rule in Excel for Windows or Mac and then reopen the file in the browser.