Excel file that highlights hardcoded numbers inside formulas using FORMULATEXT, REGEXTEST and conditional formatting

Get the Hardcoded Number Finder

The exact file from the video. Both regex patterns, the conditional formatting rule, the exception list, and the AI prompt for tuning it to your own rules.

To find hardcoded numbers inside Excel formulas, combine FORMULATEXT and REGEXTEST in a conditional formatting rule: 

=REGEXTEST(FORMULATEXT(A1),$U$9)

where $U$9 holds your regex pattern. Every formula containing a number that matches the pattern highlights itself.

Go To Special cannot do this, because those cells count as formulas, not constants.

Key Takeaways
  • Go To Special only finds numbers typed into cells. A number sitting inside a formula stays invisible to it.
  • Use FORMULATEXT to pull the formula out as text. Once it’s text, you can search it.
  • Wrap it in REGEXTEST to check that text against a pattern. TRUE means a hardcoded number is in there.
  • Run it as a conditional formatting rule. The risky formulas highlight themselves, with no helper columns down the side of your model.
  • Not every number in a formula is an error. Keep an exception list for the ones you use on purpose, like the decimal places in ROUND.
  • REGEXTEST needs Microsoft 365 or Excel for the web. It is not in Excel 2024, 2021 or earlier.

Go To Special Only Finds Half the Problem

Home > Find & Select > Go To Special > Constants > Numbers selects every hardcoded value typed directly into a cell. That part is easy.

The sneaky ones are the numbers sitting inside a formula. A rate typed into a calculation. A plus 2,500 added during a late edit. Go To Special skips right past them, because the cell contains a formula.

You can flip on Show Formulas with Ctrl + ` and see everything at once. On a real model that’s just a wall of text.

Step 1: Pull the Formula Out as Text

FORMULATEXT returns a formula as plain text:

=FORMULATEXT(C10)

Now it’s searchable.

Step 2: Test It Against a Pattern

REGEXTEST checks that text for a pattern and returns TRUE or FALSE:

=REGEXTEST(FORMULATEXT(C10),$U$9)

FALSE means nothing matched. TRUE means a hardcoded number was spotted.

A regex pattern looks like someone fell asleep on the keyboard, but all it does is describe a shape of text to look for. Numbers in certain spots. That’s it. If you want the full breakdown, see our guide to regex in Excel. AI is also very good at writing these patterns for you.

Step 3: Turn It Into a Conditional Formatting Rule

Helper columns down the side of your model defeat the purpose. Conditional formatting does the same job invisibly.

  1. Select the range you want to check, starting from the top-left cell.
  2. Go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
  3. Enter =REGEXTEST(FORMULATEXT(A1),$U$9). Change A1 to the top-left cell of your selection. Lock the pattern cell with F4.
  4. Pick a fill color and confirm.

Every formula with a hardcoded number now shows up in color. Fix one, reference the input cell instead, and the highlight disappears on its own.

Not Every Number in a Formula Is a Problem

This is where a blunt pattern gets annoying. Some numbers are meant to be there:

  • The 0 in ROUND that sets decimal places
  • Row and column numbers inside INDEX
  • Dividing an annual figure by 12 to get a monthly one
  • SUBTOTAL arguments like 9 for SUM or 5 for MIN

But dividing some other number by 12 might not be fine. Context decides, not the pattern.

That’s why the file includes two patterns. One flags any number sitting after an operator, a comma or a bracket. The other has a longer exception list and ignores standalone zeros and ones. If a number is routine in your model, add it to the exceptions and the highlights for it stop.

There’s also a dropdown in the file that switches between patterns using XLOOKUP. Point the conditional formatting rule at the XLOOKUP result instead of a fixed cell, and you can change the whole review level from one dropdown.

If You Have a Copilot License

Copilot understands context better than a pattern does. In editing mode, try this prompt:

Highlight only meaningful hard-coded values in formulas in the sheet or the workbook, not routine math constants typical to models like this.

In testing it correctly ignored the routine constants, including SUBTOTAL arguments that regex would flag unless you add them to the exception list.

What This Won’t Catch

These patterns are experiments, not a guarantee. Regex only sees text. It doesn’t understand Excel, and it can’t tell an intentional 12 from a careless one.

Treat it as a starting point. The file includes a prompt you can paste into any AI tool: tell it what you want to catch, tell it what you want to ignore, and it tunes the pattern to your rules.

Download the Workbook

The exact file from the video. Both regex patterns, the conditional formatting rule, the exception list, and the AI prompt for tuning it to your own rules.

Get the Hardcoded Number Finder

Both regex patterns, the conditional formatting rule, and the exception list from this post. Free download.

If you want to go deeper into reading and building financial reports the way a controller actually does, that’s what we cover in Understanding Financial Analysis.

Featured Course

Fundamentals of Financial Analysis

Read financial statements properly and learn the Excel formulas behind financial reporting. For people moving into finance, and for people who want to be sure nothing is missing.
Learn More
Financial Analysis Course Cover

Frequently Asked Questions

How do I find hardcoded numbers inside Excel formulas?

Use a conditional formatting rule with =REGEXTEST(FORMULATEXT(A1),$U$9), where $U$9 holds a regex pattern that describes the numbers you want to catch. FORMULATEXT converts the formula to text and REGEXTEST checks it for a match.

Does Go To Special find hardcoded values in formulas?

No. Go To Special > Constants > Numbers only selects numbers typed directly into cells. A number inside a formula lives in a cell Excel treats as a formula, so it is never selected.

What does FORMULATEXT do?

FORMULATEXT returns a cell’s formula as text. It’s the step that makes a formula searchable. It returns #N/A for cells that don’t contain a formula, which in a conditional formatting rule simply means no highlight is applied.

Do I need Microsoft 365 for this?

For the regex method, yes. REGEXTEST is available in Microsoft 365 and Excel for the web only. FORMULATEXT works from Excel 2013 onward, but on its own it won’t test the pattern for you.

Why is nothing highlighting?

Two usual causes. The cell reference in the rule must match the top-left cell of your selected range, and the reference to the pattern cell must be absolute, so press F4 on it.

Which hardcoded numbers are safe to leave alone?

Numbers that are part of how a function works: decimal places in ROUND, position arguments in INDEX, SUBTOTAL function numbers, and standard conversions like dividing by 12 for a monthly figure. Everything else deserves a look.

Leila Gharani

Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.