Conditional Formatting in a Pivot Table That Survives Refresh
By ExcelReady TeamUpdated 6 min read
The short answer
To keep conditional formatting in a pivot table after a refresh, apply the rule to the value field, not to fixed cells. After you add the rule, click the Formatting Options button and choose "All cells showing 'Sum of Sales' values for 'Region'". The rule then follows the field as rows change, and it leaves out subtotals and grand totals.
Key takeaways
- A rule scoped to 'Selected cells' covers fixed addresses, so it misses new rows after a refresh.
- Scope rules to the value field instead; Excel offers this in the Formatting Options button and the Apply Rule To section.
- The 'for Region' option leaves out subtotals and grand totals, which would otherwise distort averages, top 10 rules and colour scales.
- Fix existing rules in Home > Conditional Formatting > Manage Rules, with 'This PivotTable' selected.
On this page+
- Why does pivot table conditional formatting break after a refresh?
- How to apply conditional formatting to a pivot table
- The three "Apply rule to" options explained
- Why you should leave out the grand total
- How to fix a rule that stopped working
- Which conditional formatting rules work best in a pivot?
- Common problems with pivot conditional formatting
- Practise it
Conditional formatting in a pivot table survives a refresh when the rule is tied to the value field, not to a block of fixed cells. Excel asks how to scope the rule each time you add one, and the choice decides whether new rows get coloured and whether the grand total spoils the result. This guide is for anyone who builds pivot reports that are refreshed every week and wants the highlights to keep working.
Why does pivot table conditional formatting break after a refresh?#
It breaks because the rule points at fixed cells while the pivot keeps changing shape. A normal conditional formatting rule applies to a range such as B5:B9. A pivot table can grow, shrink or move its values every time you refresh, filter or drag a field.
Say a rule covers B5:B9 for five regions. Next month a sixth region appears and the pivot fills B5:B10. B10 has no rule, so it stays plain. If you move Region to Columns, the values move to a row and the old range now highlights the wrong cells, or empty ones.
Pivot tables solve this with field-based scopes. A rule scoped to "Sum of Sales" follows those values wherever they appear. If refreshing itself is the problem, see why a pivot table doesn't update and how to refresh it.
How to apply conditional formatting to a pivot table#
Apply the rule as usual, then change its scope:
- Click one value cell in the pivot, for example the Sum of Sales for Central.
- Go to Home > Conditional Formatting and pick a rule, such as Top/Bottom Rules > Above Average or Data Bars.
- A small Formatting Options button appears next to the cell. Click it.
- Choose All cells showing "Sum of Sales" values for "Region".
The rule now covers every region value, today and after any refresh. If you create the rule from Conditional Formatting > New Rule instead, the same three choices appear at the top of the dialog under Apply Rule To. The basics of each rule type are in the conditional formatting guide.
The three "Apply rule to" options explained#
Excel gives you three scopes. The names use your own field names, so they change with your data:
| Option | What it covers | Survives refresh? | Includes totals? |
|---|---|---|---|
| Selected cells | The exact cells you selected | No: new rows are missed | Only if you selected them |
| All cells showing "Sum of Sales" values | Every Sum of Sales cell in the pivot | Yes | Yes: subtotals and grand totals too |
| All cells showing "Sum of Sales" values for "Region" | Sum of Sales cells at the Region level | Yes | No |
The third option is the right default for most reports. Use the second only when you really want totals compared with items, which is rare.
If your pivot has two row fields, such as Region and Month, the third option is tied to the level of the cell you clicked. Click a month value first and the rule covers the month rows, not the region subtotals.
Why you should leave out the grand total#
Rules such as Above Average, Top 10 and colour scales compare every cell in their range, and a grand total is far bigger than any single item. Here is a pivot of sales by region:
| Region | Sum of Sales |
|---|---|
| Central | 18,400 |
| East | 22,750 |
| North | 15,900 |
| South | 26,300 |
| West | 19,650 |
| Grand Total | 103,000 |
With the third option, the average of the five regions is 20,600, so Above Average highlights two regions: East and South. You can check that count with a formula on the values:
=COUNTIF(B2:B6,">"&AVERAGE(B2:B6))The result is 2. With the second option, the grand total joins the range. The average of all six cells becomes 34,333, and the only cell above it is the grand total itself. The rule "works", but it tells you nothing. The same happens with a colour scale: the total takes the darkest colour and every region looks pale.
How to fix a rule that stopped working#
You can rescope an existing rule without starting again:
- Click any cell inside the pivot.
- Go to Home > Conditional Formatting > Manage Rules.
- In Show formatting rules for, choose This PivotTable.
- Select the rule and click Edit Rule.
- Under Apply Rule To, pick the field-based option and click OK.
While you are in Manage Rules, delete duplicates. Applying a rule to "Selected cells" several times over the months often leaves a stack of near-identical rules. The rules list also shows the order Excel applies them in, which matters when two rules colour the same cell.
Which conditional formatting rules work best in a pivot?#
Most rule types work in a pivot. These are the ones that read best in a report:
- Data bars show size at a glance. Leave totals out or every bar looks short.
- Top 10 Items or Top 10% pick out the leaders. You can change 10 to 3 for a top-three highlight.
- Above or below average split items into two groups.
- Greater than a value flags anything over a target, such as sales above 20,000.
- Icon sets work well with a "% of total" value field, where every item is on the same scale. The guide to showing percent of total in a pivot table sets that up.
Formula rules work too. Choose Use a formula to determine which cells to format, write the formula for the cell you clicked, such as =B5>20000, and then pick the field-based scope. Rules can also target a calculated field; the guide to pivot table calculated fields shows how to add one.
Common problems with pivot conditional formatting#
If the colours still look wrong, check these:
- The value field was removed and added back. Removing a field from the pivot removes its rules. Add the rule again after the layout is final.
- The rule colours dates or labels. Rules on row labels need the "Selected cells" scope or a formula rule. For grouped dates, see how to group dates in a pivot table.
- The rule depends on a filter. A Top 3 rule ranks only the items currently visible, so filtering the pivot changes which items are highlighted. That is usually what you want.
- Manual colours fight the rule. "Preserve cell formatting on update" in PivotTable Options keeps manual fills, not conditional formatting. Clear manual fills so the rule is the only source of colour.
Practise it#
The skills behind this are conditional formatting rules and confident pivot work. Practise conditional formatting in a live spreadsheet, then build and rearrange summaries in the pivot tables lesson. Each lesson checks your work instantly. The exercise on this page shows how to confirm what an Above Average rule will highlight.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
This is a pivot's output with the grand total left out. An Above Average rule highlights regions whose sales beat the average. In D2, count how many regions it highlights: use COUNTIF on B2:B6 with ">"&AVERAGE(B2:B6) as the criteria.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Sum of Sales | Highlighted | |||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | |||||
| 7 | |||||
| 8 | |||||
| 9 |
Tip: Join the operator to the average with &: ">"&AVERAGE(B2:B6).
Practise this in a lesson
Frequently asked questions
Why does conditional formatting disappear when I refresh my pivot table?
The rule was probably applied to selected cells, which are fixed addresses. When the pivot changes size or layout, those cells no longer match the data. Edit the rule and apply it to all cells showing the value field instead.
How do I apply conditional formatting to a pivot table without the grand total?
Apply the rule, then choose the third option under Formatting Options or Apply Rule To: All cells showing 'Sum of Sales' values for 'Region'. That scope covers the item rows only and leaves out subtotals and grand totals.
Can I use a formula in pivot table conditional formatting?
Yes. Choose 'Use a formula to determine which cells to format' and write the formula for the active cell, such as =B5>20000. Then set Apply Rule To to the value field so the rule follows the pivot.
Does Preserve cell formatting on update keep conditional formatting?
No. That PivotTable option keeps manual formatting, such as fill colours you set by hand. Conditional formatting depends on how the rule is scoped, so scope it to the value field.