Sub topic 13
Copying and clearing rules
This chapter assumes you can create formula-based rules, understand relative, absolute and mixed references, and can open the Conditional Formatting Rules Manager. Here you will learn how rules travel when you copy cells, what happens to their ranges, and how to remove rules without damaging other formatting.
Why copying rules needs care
A conditional formatting rule is not stored in the cell the way a fill color is. It is stored as a separate entry with a formula or condition and an Applies to range. When you copy or clear cells, Excel edits those entries behind the scenes. Most surprises come from this: a copy adds new entries, a cut changes ranges, and a clear can remove more than you meant.
Ways to copy a rule
Four common methods carry rules to other cells.
| Method | What it copies | Typical use |
|---|---|---|
| Format Painter (Home tab) | All formatting, including rules | Apply a rule's look to a nearby block |
| Copy, then Paste Special > Formats | All formatting, including rules, but no values | Apply formatting to a distant block |
| Ordinary copy and paste | Values, formulas, formatting and rules | Duplicating a whole row or table section |
| Fill handle with Fill Formatting Only | Formatting and rules across a dragged range | Extending a pattern down or across |
Paste Special has no "conditional formatting only" option. Any method that copies formats also copies number formats, borders and fonts. If the destination already has formatting you want to keep, expect it to be overwritten.
Format Painter
- Select a cell that carries the rule, for example A2 from a rule applied to
$A$2:$E$50. - Click Format Painter on the Home tab. Double-click it to paint several areas.
- Select the destination cells.
The destination now has the rule. The rule is also added to the Rules Manager as an entry covering the destination.
Paste Special Formats
Copy the source cells, select the destination, then choose Home > Paste > Paste Special > Formats. The destination keeps its own values and receives the source's formatting and rules. This is the safest method when the destination already holds data.
Fill handle
Select the formatted cells, drag the fill handle, then open the Auto Fill Options button and pick Fill Formatting Only. Without that choice, Excel also fills values or continues a series.
What happens to references when you copy
Excel adjusts the relative parts of a rule formula based on the position of the pasted cells. This works the same way as copying an ordinary formula.
Suppose this rule is applied to $A$2:$E$50 with A2 as the active cell:
=$C2>1000If you copy A2:E2 to A60:E60, the new entry applies to $A$60:$E$60 and its formula becomes:
=$C60>1000The column is locked, so each cell in the new row still tests column C. The row is relative, so row 60 tests row 60. This is the behavior you want.
Now compare a rule that points at a fixed cell:
=A2>$H$1If you copy A2 to A60, the formula becomes =A60>$H$1. The threshold in H1 stays fixed because it is absolute. If H1 had been written as H1, the copy would test H59, which is probably empty. That produces a rule that silently never fires.
How ranges fragment
Each copy can add an entry. After several paste operations, the Rules Manager may show many entries with the same rule but different Applies to ranges, such as $A$2:$E$50, $A$60:$E$60 and $A$70:$E$70. The rules still work, but they are tedious to maintain, because a change to the threshold must be made in every entry.
To consolidate them:
- Open Home > Conditional Formatting > Manage Rules.
- Set "Show formatting rules for" to This Worksheet.
- Edit one entry so its Applies to range covers all the blocks, separating areas with commas, for example
=$A$2:$E$50,$A$60:$E$60. - Delete the duplicate entries.
Only merge entries whose formulas are identical when read from the top-left cell of the combined range. If the first area starts at row 2 and a second area starts at row 60, a formula written from A2 is still correct for the second area, because relative references are evaluated against the top-left cell of the first area in the list. Check the result visually after merging.
What happens when you cut and move cells
Cut and paste behaves differently from copy. The rule entry follows the cells. If you cut A2:E10 and paste it elsewhere, the Applies to range of the existing rule shrinks to exclude the moved cells and a new entry is created for the destination. References inside the formula that pointed to the moved cells are updated to follow them.
Inserting and deleting rows also changes ranges:
- Inserting a row inside the Applies to range extends the range.
- Inserting a row just below the range does not extend it, so the new row is unformatted.
- Deleting rows shrinks the range, and deleting the whole range removes the rule.
Sorting is safe when the rule uses references within the same row, as in =$C2>1000. Rules that use relative references to other rows, such as =A2<A1, can change meaning after a sort. Test after sorting.
Copying between sheets and workbooks
Pasting formats into another sheet creates new entries for that sheet. The rule does not stay linked to the original.
Between workbooks, two points need attention:
- If a rule formula refers to another sheet, the pasted rule may keep a reference to the source workbook. Check the formula in the Rules Manager and replace it with a reference to a local cell.
- Colors are stored with the workbook theme. If the destination workbook uses a different theme, theme-based colors can look different. Use standard colors or RGB values when appearance must match exactly.
Clearing rules
Clearing removes the rule entry or shrinks its Applies to range. Choose the narrowest option that does the job.
Clear Rules commands
Go to Home > Conditional Formatting > Clear Rules and choose one of these:
- Clear Rules from Selected Cells removes rules from the selection only. A rule that covered a larger range keeps applying to the rest.
- Clear Rules from Entire Sheet removes every conditional formatting rule on the active sheet.
- Clear Rules from This Table is available when the active cell is inside an Excel table.
- Clear Rules from This PivotTable is available when the active cell is inside a PivotTable.
Clearing from selected cells splits or shrinks ranges. If a rule applied to $A$2:$E$50 and you clear rows 10 to 12, the rule's range becomes two areas, $A$2:$E$9,$A$13:$E$50. Use that to carve out exceptions.
Other commands that remove rules
Home > Clear > Clear Formats and Clear All also remove conditional formatting, along with fills, fonts and borders. Pressing Delete clears values only. It leaves rules in place. This is a common reason a "cleared" sheet still shows colors when new data is typed in.
Deleting a single rule
To remove one rule while keeping others, use the Rules Manager. Select the entry and choose Delete Rule. Set "Show formatting rules for" to This Worksheet so you can see rules that apply outside your current selection. If you only look at the current selection, hidden entries on other areas stay unnoticed.
Choosing a method
Common problems
- A pasted rule highlights the wrong cells. The formula contained a relative reference that shifted. Open the rule in the Rules Manager and lock the column or row with
$. - Many near-identical entries. Repeated copy and paste fragmented the ranges. Merge them as described above.
- Rules disappeared after pasting values. Paste Special > Values over a range does not remove rules, but an ordinary paste from an unformatted source replaces the destination's formatting, including rules. Use Paste Special > Values when you only want data.
- Color remains after clearing. The color may be a manual fill, not a rule. Use Clear Formats on that range, or check whether the fill is applied under the rule.
- Rules still active after deleting rows. Another entry may cover the remaining area. Check the Rules Manager for the whole sheet.
Worked example: duplicating a block
You have a tracking table in A1:E50 with the rule =AND($B2<>"",$C2="") applied to $A$2:$E$50. You add a second table in A60:E100 with the same layout and want the same rule.
- Select A2:E50.
- Click Format Painter, then select A61:E100.
- Open the Rules Manager and set it to This Worksheet.
- Check the new entry. Its formula should read
=AND($B61<>"",$C61="")if the active cell is A61. - If the first entry shows a different row in the formula, edit the entry so the formula matches its range's top-left cell.
The rule now works for both tables, and you can merge the entries if you want a single place to edit.
Exercise
A rule =$C2>1000 is applied to $A$2:$E$50. You select rows 20 to 22 and choose Clear Rules from Selected Cells. What is the Applies to range afterward, and does the rule still work in rows 23 to 50?
Show answer
The range becomes $A$2:$E$19,$A$23:$E$50. The rule still works in rows 23 to 50 because the formula is evaluated relative to the top-left cell of the first area, so each row still tests its own column C value.
Exercise
You copy a cell with the rule =A2>H1 (where H1 is meant to be a fixed threshold) down to A60. The copied cell never highlights. Why, and how do you fix it?
Show answer
The reference H1 is relative, so after copying it points to H59, which is empty. Edit the rule in the Rules Manager and change it to =A2>$H$1 so the threshold stays fixed.
Exercise
After pressing Delete on a range, colors still appear when you type new values. Which command removes the rules, and which command removes manual fills too?
Show answer
Use Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells to remove the rules. Use Home > Clear > Clear Formats to remove both rules and manual fills and other formatting.