Sub topic 16
Number formats for checks and flags
This chapter assumes you can write simple formulas, know the difference between a stored value and a displayed value, and have met the three-section custom format pattern (positive; negative; zero) from the earlier chapters. Here you will use that pattern to turn a model check, which is a raw number, into a visible flag that a reviewer can read at a glance.
Why checks need a visible flag
A financial model contains many identities that must hold. Total assets equal total liabilities plus equity. The cash on the balance sheet equals the closing cash on the cash flow statement. Segment revenue sums to consolidated revenue. Each identity is tested by a check cell, a formula that subtracts one side from the other. A correct model returns zero.
A raw zero is easy to miss. So is a small error such as 0.0004, which can display as "0.00" or "-". A check that nobody notices does no work. A number format can turn the result into a word such as OK or ERROR, in a color. The cell still holds the number, so other formulas can use it.
Format sections and conditions
A custom number format has up to four sections separated by semicolons.
| Sections written | Meaning |
|---|---|
| One | Applies to every number |
| Two | First for positive and zero, second for negative |
| Three | Positive; negative; zero |
| Four | Positive; negative; zero; text |
Two tools matter for checks:
- Color codes in square brackets, such as
[Green]and[Red], color the cell text. Other names include[Blue],[Magenta],[Cyan],[Yellow]and[Black]. You can also write[Color 10]to pick a palette entry. - Literal text in double quotes appears instead of the number. A section that contains only quoted text hides the number and shows the text.
The format from the plan shows the idea:
[Green]"OK";[Red]"ERROR";[Green]"OK"Apply it to a cell that holds assets minus liabilities and equity. A positive value shows OK in green, a negative value shows ERROR in red, and zero shows OK in green. The sections follow the usual order: positive, negative, zero.
Notice what this format does not do. A positive difference also shows OK. If assets exceed liabilities plus equity by 5,000, the cell reads OK in green. That is a wrong result that looks right.
Making the flag catch both directions
The format flags errors only by sign, so the cell's formula should make the sign meaningful. Two common approaches are shown below.
The first approach tests the check in the formula and returns a number that the format can read. This formula returns 0 when the check passes and 1 when it fails:
=IF(ABS(C40-C55)>0.001,1,0)The matching format reverses the usual meaning of the sections. Zero is good and a positive number is bad:
[Red]"ERROR";[Red]"ERROR";[Green]"OK"Here positive and negative both show ERROR, and only an exact zero shows OK. The tolerance of 0.001 sits inside the formula, which keeps the format simple and keeps the threshold visible to anyone who reads the formula.
The second approach uses a condition inside the format itself. Conditions go in square brackets and compare the cell to a number:
[Red][>0.001]"ERROR";[Red][<-0.001]"ERROR";[Green]"OK"The first two sections each carry a condition, and the third section catches everything else. This lets one cell hold the raw difference while the display shows a flag. The cost is that the tolerance is now hidden in the format, where few people look. Prefer the formula approach when the threshold may change.
Why a tolerance matters
Excel stores numbers in binary floating point, so arithmetic that is exact on paper may leave a tiny residue. A balance sheet that balances can return 1.4E-11 instead of 0. A strict test of "equals zero" then fails, and a format that expects exact zero shows ERROR on a balanced model.
Two defenses work well:
- Round inside the check:
=ROUND(C40-C55,3). The result is a clean zero when the difference is below half a thousandth. - Compare against a tolerance held in a named input cell, such as
Check_Tol, so that the threshold sits with the other assumptions and follows the input color convention.
A master check
A model with 30 check cells needs one summary. Add up the absolute values of the individual checks, or count the failures, and display the total at the top of every sheet.
=SUMPRODUCT(--(ABS(Checks!D5:D34)>Check_Tol))This counts how many checks exceed the tolerance. The result is 0 for a healthy model. Format it so that the count reads as a status:
[Red]0" check(s) failing";[Red]0;[Green]"All checks OK"When the count is 3, the cell reads "3 check(s) failing" in red. At zero it reads "All checks OK" in green. The negative section is never reached by a count, but it must still exist so that the zero section sits in the third position.
Place this cell where it is always visible, for example in a frozen header row, so that every worksheet shows the model's health while you work.
Flow of a check
Conditional formatting versus number formats
Conditional formatting can also color a cell, and it can fill the background, which a number format cannot. The two tools suit different jobs.
| Need | Number format | Conditional formatting |
|---|---|---|
| Replace a number with a word | Yes | No |
| Change text color | Yes | Yes |
| Change fill color | No | Yes |
| Use more than two conditions | No | Yes |
| Travels with copy and paste of formats | Yes | Yes, but rules can multiply |
| Visible in the cell's format dialog | Yes | No, found in a separate rule manager |
A practical combination is a number format for the OK or ERROR wording and one conditional formatting rule to fill the cell red when the check fails. Keep the rules few, because copied cells can accumulate duplicate rules that slow a large workbook.
Common errors
- Reading the sign instead of the size. The OK/ERROR format from the plan treats every positive value as OK. Use it only when the formula already guarantees that any failure is negative, or switch to the absolute-value approach above.
- Hidden failures from display rounding. A check of 0.4 in a model that reports millions can display as "0.0" or "-" under a scaling format. Check cells should not use scaled formats.
- Text results in the sum. If a check returns the word "OK" from an
IFformula instead of a number, the master check cannot add it. Return numbers and let the format supply the words. - Forgotten new checks. A master check that covers
D5:D34misses a check added in row 35. Use a table or a range that includes a spare buffer, and keep a count of expected checks beside the total. - A check that cannot fail. If the balancing item is a plug that forces the balance sheet to balance, the check always passes. Confirm each check by deliberately breaking the model once and watching the flag turn red.
Exercise
A balance check cell contains the formula =C40-C55 and uses the format [Green]"OK";[Red]"ERROR";[Green]"OK". Assets exceed liabilities plus equity by 2,500. What does the cell display, and what two changes would make the check reliable?
Show answer
It displays OK in green, because the difference is positive and the first section applies. That is misleading, since the model does not balance. First, change the formula to test the size of the difference, for example =IF(ABS(C40-C55)>Check_Tol,1,0), so that a failure is always a positive 1. Second, change the format to [Red]"ERROR";[Red]"ERROR";[Green]"OK" so that any nonzero result shows ERROR and only zero shows OK. A tolerance in a named cell also protects against floating-point residue such as 1.4E-11.
Exercise
Write a number format for a master check cell that holds a count of failing checks. It should show the count followed by the text " failing" in red when the count is above zero, and "All OK" in green when the count is zero.
Show answer
[Red]0" failing";[Red]0" failing";[Green]"All OK" The first section handles positive counts, the second handles negatives (which a count never produces but which keeps the zero section in third position), and the third handles zero. The cell still stores a number, so other formulas can test it with =Master_Check=0.