Sub topic 11
Reviewing and Editing Rules in the Rules Manager
This chapter assumes you can enter data, apply basic fills and font colors, write simple formulas, and select ranges. It also assumes you have created at least one conditional formatting rule from the Home tab. You do not need to know rule precedence yet. The next chapter covers it in detail.
Why you need the Rules Manager
The Home tab gives you quick ways to create rules. It does not show you what rules already exist. After a few rounds of editing, a worksheet can hold overlapping rules, rules left behind by copy and paste, and rules that cover the wrong cells. The Conditional Formatting Rules Manager is the one place where you can see all of them, change them, and delete them.
Open it from Home > Conditional Formatting > Manage Rules. You can also press Alt, H, L, R in sequence on Windows.
Reading the dialog
The dialog opens with a drop-down at the top labeled Show formatting rules for. This setting decides which rules appear in the list.
| Setting | What the list shows |
|---|---|
| Current Selection | Only rules that apply to the cells you selected before opening the dialog |
| This Worksheet | Every rule on the active sheet |
| Other sheet names | Every rule on that sheet |
Excel often opens the dialog with Current Selection. If you select one cell and see an empty list, the cell may simply have no rules. Switch to This Worksheet before you decide that a sheet has no rules.
The list has these columns:
- Rule (applied in the order shown) shows the rule type and a short description, such as
Cell Value > 1000orFormula: =$C2>1000. - Format shows a preview of the fill, font, or border the rule applies. Data bars, color scales, and icon sets show a small graphic instead.
- Applies to shows the range the rule covers, such as
=$A$2:$E$50. - Stop If True is a check box. Chapter 12 explains it.
The order of the list matters. Rules higher in the list take priority over rules lower in the list when they conflict.
Creating a rule from the dialog
Click New Rule to open the same dialog you see from the Home tab menus. If you select the range first, Excel fills in the Applies to box for you. If you open the Rules Manager with no selection or with one cell selected, check the Applies to box and fix it before you click OK.
Editing a rule
To change a rule:
- Select the rule in the list.
- Click Edit Rule.
- Change the rule type, the condition, or the format.
- Click OK.
The Edit Rule dialog has two parts. The upper part is the list of rule types, such as "Format only cells that contain" or "Use a formula to determine which cells to format". The lower part holds the condition and the Format button.
You can change a rule's type while editing. If you switch from a cell-value rule to a formula rule, Excel does not convert the old condition for you. Retype the condition.
Editing a formula rule safely
Formula rules deserve extra care in the Edit Rule box. The formula is interpreted relative to the active cell at the moment you create or edit the rule, and that is usually the top-left cell of the Applies to range. Take this rule applied to $A$2:$E$50:
=$C2>1000It works because C2 is evaluated for the row of each cell, and the column is locked. If you edit this rule while a different cell is active, Excel may interpret the formula as relative to that cell. The result is a rule that looks the same in the list but behaves differently.
Two habits prevent this problem:
- Select the first cell of the Applies to range before you open the Rules Manager, then edit the rule.
- Do not click cells with the mouse while the cursor is in the formula box. Clicking a cell inserts a reference and can switch the box into point mode. In point mode the arrow keys move the reference instead of the text cursor, which corrupts the formula. Press F2 to switch back to edit mode, or type the references by hand.
After any edit, confirm the result on the sheet. Look at the first row, the last row, and one row that should not be highlighted.
Changing the Applies to range
Many rule problems come from the wrong Applies to range, not from the rule itself. To change it, edit the Applies to box in the Rules Manager list. You can type a range or click the small selector button at the right and drag over the cells.
Some practical patterns:
- To extend a rule to new rows, change
=$A$2:$E$50to=$A$2:$E$200. - To cover two separate blocks, separate them with a comma:
=$A$2:$E$50,$H$2:$L$50. - To use an entire column below a header, use
=$A$2:$A$1048576. This works, but it forces Excel to check a million cells per rule and can slow large files. Use a bounded range or an Excel Table where you can.
When the Applies to range changes, the formula in a formula rule does not change on its own. The formula is still anchored to the top-left cell of the new range. If you move the start of the range, for example from A2 to A5, rewrite the formula to match the new top-left cell.
Reordering, duplicating, and deleting
Select a rule and use the up and down arrow buttons to change its position. The effect on conflicting rules is covered in the next chapter.
Duplicate Rule creates a copy directly below the original. This is the fastest way to build a family of similar rules, such as one rule per status value. Duplicate, then edit the copy.
Delete Rule removes the selected rule only. It does not remove formatting that was applied by hand, and it does not affect other rules. There is no confirmation prompt, but Ctrl+Z restores the rule if you act at once.
A review workflow for an inherited workbook
When you open a workbook you did not build, use this routine.
- On each sheet, open the Rules Manager and set Show formatting rules for to This Worksheet.
- Read every row. Note the Applies to range and the formula for each rule.
- Look for duplicates: two rules with the same condition and format.
- Look for fragments: ranges such as
=$A$2:$A$2,$A$3:$A$3,$A$4:$A$4. These come from copying and pasting cells with formatting, and they make rules hard to maintain. - Look for rules whose Applies to range covers blank areas, headers, or totals rows.
- Delete what you can explain is unnecessary and fix the rest.
The workflow below shows how the checks fit together.
Rules on other sheets
The Show formatting rules for list includes every sheet in the workbook. You can edit rules on other sheets without leaving the one you are on. This is useful for a summary sheet that depends on formatting rules in a data sheet.
A rule's formula can refer to cells on other sheets in current versions of Excel. Older versions (2007 and earlier) reject direct references to other worksheets in conditional formatting formulas. If a workbook must open in an old version, use a named range that points to the other sheet instead.
Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| The list is empty but the cell is clearly formatted | The view is set to Current Selection and the selection has no rules, or the color is manual fill | Switch to This Worksheet, or check the Home tab fill |
| The rule highlights the wrong rows after an edit | The formula was edited with a different active cell, so references shifted | Select the first cell of the range, then rewrite the formula |
| The Applies to box shows many small ranges | Repeated copy and paste of formatted cells | Merge them into one range and delete duplicate rules |
| A new rule has no visible effect | It sits below a conflicting rule, or Applies to is wrong | Check order and range |
| A formula rule looks correct but nothing highlights | The formula returns text or an error instead of TRUE or FALSE | Test the formula in a helper cell |
Testing a formula before you save it
A formula rule must evaluate to TRUE or FALSE for each cell. You can test it in a helper cell. For the overdue rule from earlier chapters, put this in an empty cell in row 2:
=AND($D2<TODAY(), $E2<>"Done")If the helper cell shows TRUE for rows that should be highlighted and FALSE for others, the same text will work in the rule. Delete the helper cell afterwards.
Exercises
Exercise
You open the Rules Manager on a sheet you know has several rules, but the list is empty. You had selected cell A1 before opening the dialog. What is the most likely reason, and what do you do?
Show answer
The "Show formatting rules for" setting is on Current Selection, and A1 has no rules. Change the setting to This Worksheet to see every rule on the sheet.
Exercise
A rule with the formula =$C2>1000 applies to $A$2:$E$50. You change Applies to to $A$5:$E$50 but leave the formula alone. Which rows are now evaluated against which column C cells, and how do you fix the rule?
Show answer
The formula is anchored to the top-left cell of the range, which is now A5. Excel evaluates row 5 against C2, row 6 against C3, and so on, so each row is compared with the wrong value, three rows earlier. Rewrite the formula as =$C5>1000 while A5 is the active cell, so each row is compared with its own column C value.
Exercise
Why is it risky to click a cell with the mouse while editing a formula in the Edit Formatting Rule dialog, and how do you recover?
Show answer
Clicking inserts a reference and switches the box to point mode, so the arrow keys move the reference instead of the text cursor. This can corrupt the formula. Press F2 to return to edit mode, or type references by hand.