Sub topic 9
Finding hardcoded numbers inside formula rows
This chapter assumes you can write formulas with absolute and relative references and that you know the layout of a three-statement model. It also assumes you have used Show Formulas and Go To Special from the earlier navigation chapter.
Why hardcodes matter
A hardcode is a typed-in constant sitting where a formula should be. A row of projections might hold =D20*(1+E$8) in columns E through I, and then a plain 5200 in column H. The model still calculates. The number looks plausible, and nothing turns red. But column H no longer responds to the growth assumption, and every later year inherits the stale value.
Hardcodes get into models in a few ways:
- An analyst overwrites a formula to force a balance sheet to balance (a "plug").
- Someone pastes values over a formula range and forgets to restore it.
- A number is typed into a formula, as in
=D20*1.05. This is an embedded constant, which is harder to see than an overwritten cell. - A one-off adjustment is added, such as
=D20*(1+E$8)+300, and never documented.
Not every constant is wrong. Inputs, historical actuals, and dates are meant to be typed. The audit question is whether a constant sits in a place where the model's structure says a formula belongs.
Two kinds of hardcode
| Kind | Example | How to detect it |
|---|---|---|
| Whole-cell override | `5200` typed in a row of formulas | Go To Special, ISFORMULA, Show Formulas |
| Constant embedded in a formula | `=D20*1.05` or `=SUM(D5:D9)+300` | Go To Special with numbers ticked, FORMULATEXT, reading the formula |
The first kind is easy to find with tools. The second needs a closer look, because the cell is still a formula and ISFORMULA returns TRUE for it.
Method 1: Go To Special
Go To Special selects cells by content type. Press F5 (or Ctrl+G), click Special, and choose one of these.
- Select the projection area, for example
E20:N80. - Open Go To Special and choose Constants. Tick Numbers only and clear Text, Logicals, and Errors.
- Click OK. Excel selects every typed-in number in that range.
- Apply a fill color to the selection, or step through it with Enter.
Because you limited the selection to the projection columns, any constant that remains is suspect. In a well-built model the only constants in that area should be none at all, since inputs live on a separate section or sheet.
Choose Formulas instead to select all formula cells. With only Numbers ticked, this selects formulas that return numbers. Then colouring the formula cells and looking for uncoloured gaps in a row shows overrides visually.
A related shortcut is Ctrl+\\ (row differences). Select a row, press Ctrl+\\, and Excel selects the cells whose formulas differ from the active cell in R1C1 terms. This finds inconsistent formulas and overrides in a single keystroke. Make the first projection cell active before you press it.
Method 2: Show Formulas
Show Formulas (Ctrl+`) replaces every value with its formula text. Columns widen, and you can scan a row across the page. A consistent row looks the same in every column apart from the column letter. A hardcode appears as a bare number among formulas, and it often right-aligns differently as well.
This is quick for a small sheet and tiring for a large one. Use it to confirm what the other methods found, not as the only method.
Method 3: ISFORMULA
ISFORMULA returns TRUE when a cell contains a formula. Combined with SUMPRODUCT, one cell can count the overrides in an entire row:
=SUMPRODUCT(--NOT(ISFORMULA(D20:N20)))The double minus converts TRUE and FALSE to 1 and 0, so the result is the number of non-formula cells in the range. A result of 0 means every cell is a formula. Any other result means you should look at the row.
Note that the range must cover only the cells that are supposed to be formulas. If column D holds a historical actual that is legitimately typed, start the range at the first projected column. Otherwise the check reports a false alarm every time.
You can also apply ISFORMULA inside conditional formatting. Select E20:N80, create a rule using the formula =NOT(ISFORMULA(E20)) (written relative to the top-left cell), and set a red fill. Any constant then lights up, and it will also light up in the future when someone overwrites a formula. This turns a one-time audit into permanent monitoring.
Method 4: FORMULATEXT
FORMULATEXT returns the formula in a cell as text. Place it in a helper column or row next to the range being checked:
=FORMULATEXT(E20)Copy it across, and the helper row shows each column's formula in plain text. You can compare neighbours by eye. If the helper cell returns #N/A, the referenced cell has no formula, which is itself a hardcode signal.
To go further, compare the text of two neighbouring formulas. Because relative references change by column, the raw text of E20 and F20 will always differ. R1C1 style removes that difference. Switch to R1C1 under File > Options > Formulas, and consistent formulas then show identical text across the row. This makes a single odd formula easy to spot, whether it is a hardcode or a reference to the wrong row.
Finding constants embedded in formulas
An overwritten cell is simple to find. An embedded constant such as =D20*1.05 is a formula, so ISFORMULA and the Constants filter both pass it over. Three techniques help.
- Row differences (Ctrl+\\). The formula
=D20*1.05differs from=D20*(1+E$8)in R1C1 terms, so it is selected. - R1C1 reading. In a consistent row the R1C1 text matches across columns. A pasted number inside the formula breaks the match.
- Search by pattern. Use Find (Ctrl+F) with Look in set to Formulas. Searching for
+3or*1.finds typical plugs, though it also produces false matches. Treat results as leads, not proof.
Some constants in formulas are acceptable. =D20/12 converts annual to monthly, and =1-E8 uses the number 1 as part of the math. The rule of thumb is that a number is acceptable when it is a unit conversion or a mathematical identity. A number is a hardcode when it is a business assumption, such as a growth rate, margin, or tax rate, that could change.
A worked example
Suppose row 20 holds forecast revenue for columns E through I, which are years 1 to 5. Row 8 holds the growth rate for each year.
E20: =D20*(1+E$8)
F20: =E20*(1+F$8)
G20: =F20*(1+G$8)
H20: =5200
I20: =H20*(1+I$8)A reviewer runs three checks.
- The ISFORMULA count across
E20:I20returns 1. One cell is not a formula. - Go To Special with Constants and Numbers selects H20.
- FORMULATEXT in a helper row shows
#N/Afor H20 and the expected pattern for the others.
The fix is to restore the formula in H20 with =G20*(1+H$8). Before overwriting the value, record what it was. If 5200 was entered to match a target, that decision belongs in the findings log, because the person who typed it may have had a reason that should be handled with a visible input, not a buried constant.
Edge cases
- Hidden rows and columns. Go To Special selects cells in hidden areas, but a visual scan does not show them. Unhide before using Show Formulas.
- Merged cells. ISFORMULA on a merged range tests only the top-left cell. Avoid merged cells in calculation areas.
- Constants that match. A typed number that equals what the formula would return hides the problem until an input changes. The ISFORMULA test finds it regardless of value, which is why it beats comparing numbers.
- Pasted values with formatting. A pasted-over cell may keep the formula cell's number format, so formatting does not distinguish it.
- Text numbers. A number stored as text is a constant, and it shows up under Constants with Text ticked. It will often also carry a green triangle.
- Protected sheets. Go To Special works on protected sheets, but you cannot colour cells. Use a copy of the file for marking.
Limits of these methods
None of the methods reads intent. They report where a constant is, not whether it is wrong. A legitimate hardcode in a formula row, such as a one-time acquisition in year 3, needs a note in the model. An undocumented one is a finding even when its value is sensible.
Also, the checks look at one sheet or range at a time. A constant on another sheet, or a link to an external workbook, will not appear. The next chapters cover what tracing cannot see and how to build checks that run automatically.
Exercise
Row 30 has the formula =E29*$C$4 in columns E to N. Cell J30 contains the typed number 840. Write one formula that returns how many cells in E30:N30 are not formulas, and say what it returns here. Then name a case where a constant inside a formula would not be caught by that formula.
Show answer
Use =SUMPRODUCT(--NOT(ISFORMULA(E30:N30))). It returns 1, because only J30 is a constant. A cell such as =E29*1.05 is still a formula, so ISFORMULA returns TRUE and the count misses it. You would find it with Ctrl+\ row differences, R1C1 reading, or FORMULATEXT.
Exercise
You find =SUM(E5:E9)+300 in one projection cell, and the rest of the row is =SUM(E5:E9). Is this a hardcode, and what should you do before changing it?
Show answer
Yes. The 300 is a business adjustment embedded in the formula, not a unit conversion or an identity. Record the cell address, the formula, and its value in the findings log. Ask the model owner why it exists. If the adjustment is valid, move 300 to a labelled input cell and reference it. If not, restore =SUM(E5:E9).