MSBA-175 · Lesson 3 of 12 · 22 min
Advanced conditional formatting
▶ Video coming soon A video version of this lesson is on the way.
By late September the season bookings workbook held 430 rows, and Rosalind had a request she repeated every Monday: "Show me what needs attention, without making me read it." Teo had already added the built-in rules from the Associate course: a data bar on the fee column and a red fill on overdue balances. Dagny's third session took the same workbook further, into the part of MO-211 called apply advanced conditional formatting and filtering: custom rules, rules based on formulas, and managing several rules that apply to the same cells.
What the built-in rules cannot do
The presets under Home > Conditional Formatting (Highlight Cells Rules, Top/Bottom Rules, Data Bars, Color Scales and Icon Sets) each look at the cell being formatted and compare it with a value. They cannot format a whole row because of a value in one column, compare a cell with a different column, or combine conditions. For those jobs you need New Rule, which opens the New Formatting Rule dialog with six rule types.
| Rule type | What it does | Maple & Pine use |
|---|---|---|
| Format all cells based on their values | Two- or three-color scales, data bars and icon sets with custom thresholds | Icon set on deposit percentage with custom cut-offs |
| Format only cells that contain | Cell value, specific text, dates occurring, blanks, no blanks, errors, no errors | Highlight blank Package cells |
| Format only top or bottom ranked values | Top or bottom N or N percent | Top 10 fees of the season |
| Format only values above or below average | Above, below, or a number of standard deviations from the mean | Guest counts more than one standard deviation above average |
| Format only unique or duplicate values | Unique or duplicate | Duplicate booking codes |
| Use a formula to determine which cells to format | Any formula that returns TRUE or FALSE | Whole rows for events within 14 days with a balance due |
Customizing value-based rules
The first rule type is where data bars, color scales and icon sets are customized. Dagny wanted the deposit column, which held the share of the fee already paid as a decimal, to show a green tick at 1, an amber flag from 0.5 up to 1, and a red cross below 0.5. The preset icon set splits values into thirds by percentile, which is useless for this. In New Rule > Format all cells based on their values, she chose Icon Sets, picked the three-symbol set, and changed each Type from Percent to Number, with values of 1 and 0.5. Show Icon Only hid the number so the column read as a simple status.
The same dialog controls data bars: the minimum and maximum can be the lowest and highest values, fixed numbers, percentages, percentiles or formulas, and the Negative Value and Axis button sets how negative values draw. For color scales you choose two or three colors and the value at each point. Setting fixed numbers rather than relative ones matters when the data changes, because a percentile-based scale recolours everything whenever a single extreme value arrives.
Worked problem
Icon thresholds that mean something
The Deposit paid share column holds values from 0 to 1. Rosalind wants a green icon when the full deposit is paid, amber when at least half is paid and red below half. The preset icon set gives the wrong results. What does Dagny change?
Show solution
- Select the column and choose Home > Conditional Formatting > New Rule > Format all cells based on their values.
- Format Style: Icon Sets. Choose a three-icon set.
- For the first icon set Type to Number, operator >=, value 1. For the second set Type to Number, operator >=, value 0.5.
- Tick Show Icon Only if the number is shown elsewhere, and click OK.
Answer: Fixed number thresholds tie the icons to business meaning rather than to where a value falls among the others.
Rules that use formulas
The sixth rule type, Use a formula to determine which cells to format, is the most powerful and the one the exam tests most. You type a formula that returns TRUE or FALSE; wherever it returns TRUE, the format applies. The formula is written as if for the top-left cell of the selected range, and Excel adjusts it for every other cell, exactly as it would if you copied an ordinary formula. That is why the dollar signs matter.
Rosalind's main request was: highlight the whole row of any booking whose event is within the next 14 days and whose status is not Paid. The bookings data ran from row 5 to row 434, with Event date in column D and Status in column H. Dagny selected A5:J434 so the format would cover the row, then entered this rule:
=AND($D5-TODAY()<=14, $D5>=TODAY(), $H5<>"Paid")Getting the anchors wrong produces three classic failures. With a fully absolute reference to D5, dollar signs before both the column and the row, the whole range follows row 5 and every row lights up or none does. With D5 and no dollar sign, each cell checks the column in its own position, so the formatting shifts across the row. With the correct $D5, every cell in a row checks column D of that row. A good test is to look at a row you know should be highlighted and one that should not.
| Goal | Range selected | Formula |
|---|---|---|
| Shade every other row | A5:J434 | =MOD(ROW(),2)=0 |
| Highlight weekend events | D5:D434 | =WEEKDAY($D5,2)>5 |
| Flag fees below the package minimum | G5:G434 | =$G5<XLOOKUP($E5,PackageCodes,PackageMinimums) |
| Highlight a row matching a client typed in L2 | A5:J434 | =$B5=FindClient |
| Mark duplicate booking codes | A5:A434 | =COUNTIF(BookingCodes,$A5)>1 |
The fourth row is a favorite trick. Dagny put a cell labeled "Find client" at L2. The rule compares each row's client with L2, so typing a name highlights that client's bookings. Dagny named L2 FindClient. A name always points at the same cell, so it behaves like a fully absolute reference, with dollar signs before both the column and the row: every cell in the range must look at the same input cell. The last row uses a name, BookingCodes, for the whole code column for the same reason.
Formula rules have limits. They cannot refer to other workbooks directly; use a named range or a helper column instead. In older versions they could not refer to other sheets without a name, but Microsoft 365 allows references to other sheets in the same workbook. Structured references such as Packages[Code] cannot be typed into a rule at all. Use a name that refers to the table column instead, as Dagny did with PackageCodes and PackageMinimums, and the rule still grows with the table.
Worked problem
Highlight the next 14 days
Dagny wants entire rows A5:J434 shaded light gold when the event in column D is within 14 days from today and column H is not "Paid". What range, formula and order of steps produce it?
Show solution
- Select A5:J434, starting the selection at A5 so it is the active cell.
- Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
- Enter =AND($D5-TODAY()<=14,$D5>=TODAY(),$H5<>"Paid").
- Click Format, choose a light gold fill, and click OK twice.
Answer: Because the formula is written for A5 with locked columns, each row is tested against its own date and status.
Text, dates and blanks in formula rules
Many real conditions involve text or dates rather than numbers, and formula rules handle them with the same functions you would use in a worksheet. Text comparisons in Excel are not case-sensitive, so ="paid" matches "Paid". To test whether a cell contains a word anywhere, use SEARCH inside ISNUMBER: SEARCH returns the position of the text or an error, and ISNUMBER turns that into TRUE or FALSE. Dagny used this to gray out any booking whose Notes column mentioned "tentative".
=ISNUMBER(SEARCH("tentative",$J5))
=AND($D5>=DATE(2027,6,1),$D5<=DATE(2027,8,31))
=$E5=""
=AND($G5>0,$H5="Due later",$D5<EDATE(TODAY(),1))
=ISERROR($K5)Dates are numbers in Excel, so date conditions are comparisons. TODAY() makes a rule move with the calendar, which is exactly what the urgency rule needs, while DATE(year, month, day) fixes a boundary. The built-in Highlight Cells Rules > A Date Occurring offers options such as Yesterday, Next week and Last month, but it cannot express "within 14 days and not paid", so the formula rule is still needed.
Blank cells are a common source of false highlights. An empty cell compares as zero with numbers and as an empty string with text, so a rule such as =$G5<500 lights up every row where the fee has not been entered yet. Adding a test for the blank, as in =AND($G5<>"",$G5<500), fixes it. Likewise, a cell containing an error makes the whole rule formula return an error, which Excel treats as FALSE, so the format quietly fails to appear. Wrapping the risky part in IFERROR, or testing with ISERROR first, makes the behavior predictable.
Finally, keep the formula readable. Long rules are hard to audit in the small Edit Rule box. When a condition becomes complicated, Dagny calculates it in a helper column, for example a column called Urgent that returns TRUE or FALSE, hides that column if needed, and points the rule at it with =$L5. The rule stays short, and anyone can check the logic in the worksheet.
Managing several rules
Once a range has more than one rule, the order and interaction of the rules matter. Home > Conditional Formatting > Manage Rules opens the Conditional Formatting Rules Manager. Its Show formatting rules for list switches between the current selection, a sheet, or a table, which is the only way to find rules applied somewhere you have forgotten.
Rules are evaluated from the top of the list down. When two rules apply to a cell and their formats do not conflict (one sets a fill, the other bold), both appear. When they conflict (two different fills), the rule higher in the list wins. The Move Up and Move Down arrows change the order. Each rule also has a Stop If True check box: when that rule is true for a cell, Excel does not evaluate the rules below it for that cell. Stop If True is mainly used to suppress icon sets or data bars for some cells, because those formats cannot otherwise be "overridden".
Dagny's final rule set for the Bookings sheet had three rules. At the top, a formula rule turned canceled bookings gray, with Stop If True ticked so canceled events never showed the gold urgency fill or a deposit icon. Second was the 14-day urgency rule. Third was the icon set on the deposit column. In the Rules Manager you can also edit a rule's Applies to box directly, which is how she extended all three rules when the season grew past row 434: changing the end row to 600 in each Applies to box, or better, converting the data to a table so the rules expand automatically as rows are added.
Other actions in the manager are Edit Rule, Delete Rule and Duplicate Rule. To remove every rule at once, use Conditional Formatting > Clear Rules > Clear Rules from Entire Sheet or from Selected Cells. Copying cells with Format Painter or ordinary paste copies their rules too, and over time this creates many fragmented rules with odd Applies to ranges. Checking the Rules Manager for "This Worksheet" and merging those duplicates is a routine clean-up step.
Filtering by format
The exam objective includes filtering. Once conditional formatting colors cells, AutoFilter can filter on that color: open the column's filter arrow, choose Filter by Color, and pick a cell color, font color or cell icon. Sort by Color works the same way and can bring all gold rows to the top. Rosalind's Monday view became a filter: Filter by Color, gold, which showed only the urgent bookings, sorted by date.
For more complex filters, Data > Sort & Filter > Advanced filters a range using a criteria range on the sheet. Criteria on the same row are joined with AND; criteria on separate rows are joined with OR. The Advanced Filter dialog can also Copy to another location and tick Unique records only, which is another way to extract a distinct list. Lesson 7 covers the FILTER function, which does the same job with a live formula.
Common mistakes
MistakeSelecting the range from the bottom up, then writing the formula for the first row.
InsteadWrite the formula for the active cell of the selection, normally its top-left cell.
MistakeLocking both the column and the row of D5 in a row-highlighting rule.
InsteadUse $D5 so the column is fixed and the row changes.
MistakeLeaving icon sets on percentiles for business thresholds.
InsteadSet each icon's Type to Number with real cut-offs.
MistakeExpecting a lower rule's fill to override a higher rule's fill.
InsteadHigher rules win conflicts; reorder with Move Up and Move Down.
MistakeSearching only the current selection for a stray rule.
InsteadShow rules for This Worksheet in the Rules Manager.
Summary and key terms
- New Rule offers six rule types; the formula type handles any condition that returns TRUE or FALSE.
- Write formula rules for the top-left cell of the range and anchor columns or rows with dollar signs.
- Value-based rules can use fixed numbers, percentages, percentiles or formulas as thresholds.
- The Rules Manager controls order, Applies to ranges, editing and Stop If True.
- AutoFilter and Sort can work by cell color, font color or icon; Advanced Filter uses a criteria range.
- Formula-based rule
- A conditional format that applies wherever a formula returns TRUE.
- Applies to
- The range a conditional formatting rule covers.
- Stop If True
- A rule option that prevents lower rules from being evaluated for cells where it is true.
- Rules Manager
- The dialog that lists, orders and edits conditional formatting rules.
- Icon set
- A conditional format that shows symbols according to thresholds.
- Advanced Filter
- A filter that uses a criteria range and can copy results elsewhere.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Which rule type formats an entire row based on one column?
Show answer
Use a formula to determine which cells to format.
In =$H5="Overdue", what does the dollar sign do?
Show answer
Locks the column, so every cell in the row checks column H.
When two rules set different fills, which one shows?
Show answer
The rule higher in the Rules Manager list.
How do you show only rows with a gold conditional fill?
Show answer
AutoFilter > Filter by Color > the gold fill.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.