Hardcoded Numbers vs Cell References in Excel Formulas
By ExcelReady TeamUpdated 7 min read
The short answer
Put any number that could change, such as a tax rate, commission rate or target, in its own input cell and point your formulas at it with an absolute reference like $E$1. Then one edit updates every result. Hardcode only true constants that never change, such as 12 months in a year or 100 in a percentage.
Key takeaways
- A hardcoded number is a value typed inside a formula, like the 0.04 in =B2*0.04.
- An input cell holds the number once, and every formula points to it, so one change updates them all.
- Lock the input cell with $ ($E$1) so the reference doesn't move when you fill the formula down.
- Hardcoding is fine for fixed facts, like 12 months or 7 days, that will never be edited.
- Show Formulas (Ctrl+` on Windows and Mac) and Trace Precedents help you find numbers hidden inside formulas.
On this page+
- Hardcoded numbers vs cell references at a glance
- A side-by-side example: a sales commission sheet
- Why the input cell needs a $ sign
- When to use cell references (input cells)
- When hardcoding is fine
- How to find hardcoded numbers in a sheet
- What a job test usually checks
- Common mistakes with hardcoded numbers
- Our recommendation
- Practise it
Hardcoded numbers in Excel formulas are values typed straight into the formula, like the 4% in =B2*0.04. A cell reference points to a cell that holds the value instead, like =B2*$E$1. Use cell references for anything that might change, and hardcode only fixed facts such as 12 months in a year. This guide is for anyone building sheets other people will check, and for job seekers who want their test answers to look like real work.
Hardcoded numbers vs cell references at a glance#
The difference is where the number lives: inside every formula, or once, in a cell everyone can see.
| Feature | Hardcoded (=B2*0.04) | Cell reference (=B2*$E$1) |
|---|---|---|
| Where the number lives | Inside each formula | In one input cell |
| Can a reader see the assumption? | Only by opening each formula | Yes, it's on the sheet |
| Changing the rate | Edit every formula | Edit one cell |
| Risk when it changes | A missed formula stays wrong, with no error | None, every formula updates |
| Works for "what if" tests | No | Yes, type a new value and watch |
| Good for | Fixed facts: 12, 7, 24, 100 | Rates, prices, targets, thresholds |
Needs $ when filled down? | No | Yes, lock the input cell |
A side-by-side example: a sales commission sheet#
Here is the same commission sheet built both ways. Each rep earns 4% of their sales.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Rep | Sales | Commission | Rate | 4% |
| 2 | Ana | 18,400 | |||
| 3 | Ben | 22,150 | |||
| 4 | Chloe | 9,800 | |||
| 5 | Dev | 31,000 |
Version 1, hardcoded: C2 holds =B2*0.04, filled down to C5.
Version 2, cell reference: C2 holds =B2*$E$1, filled down to C5.
Both give the same results today:
| Rep | Sales | Commission at 4% |
|---|---|---|
| Ana | 18,400 | 736 |
| Ben | 22,150 | 886 |
| Chloe | 9,800 | 392 |
| Dev | 31,000 | 1,240 |
| Total | 81,350 | 3,254 |
Now the sales manager raises the rate to 4.5%.
- Cell reference version: type 4.5% in E1. Every row updates at once: 828, 996.75, 441 and 1,395, for a total of 3,660.75.
- Hardcoded version: you open C2, C3, C4 and C5 one by one and change 0.04 to 0.045. Say you miss C4. Chloe stays at 392 instead of 441, and the total shows 3,611.75. That's 49 short, and nothing on the sheet looks wrong.
With 4 rows, you might catch it. With 400 rows spread over several sheets, you probably won't. That's the real cost of hardcoding: not the typing, but the silent mistake.
Why the input cell needs a $ sign#
The input cell must be locked with an absolute reference ($E$1) so it doesn't move when you fill the formula down. Without the $ signs, =B2*E1 in C2 becomes =B3*E2 in C3. E2 is empty, so Ben's commission shows 0, again with no error.
You don't have to type the dollar signs. While editing, put the cursor on E1 and press F4 on Windows, or ⌘T (or fn+F4) on a Mac. Our comparison of relative vs absolute references explains all four reference types, and mixed references cover grids where you lock only the row or only the column.
When to use cell references (input cells)#
Use an input cell for any number that is a decision, an estimate or a figure someone else gave you. That covers most numbers in business sheets.
- Rates: tax, commission, discount, interest, exchange rates.
- Prices and costs: a unit price, a shipping fee, an hourly rate.
- Targets and thresholds: a sales target in
=IF(B2>=$E$2,"Bonus",""), a minimum order size, a pass mark. - Dates that drive a report: a period end date or a cut-off.
Group these inputs in one clearly labelled area, often at the top of the sheet or on a separate Inputs sheet. Many people colour input cells differently so readers know what they're allowed to change. Excel's Home > Cell Styles gallery includes an Input style for exactly this. Building a model around a tidy set of inputs is the core idea behind any Excel financial model.
Named inputs: an easy upgrade#
You can give the input cell a name and use it in formulas. Select E1, click the Name Box to the left of the formula bar, type CommissionRate and press Enter. Now you can write:
=B2*CommissionRateIt reads like a sentence, and a name never shifts when you fill down, so you don't need $ signs. The trade-offs are covered in named ranges vs cell references.
When hardcoding is fine#
Hardcode a number only when it's fixed by definition and nobody would ever edit it. Good examples:
=B2/12to turn an annual salary into a monthly one.=C2*24to turn a fraction of a day into hours.=B2*(1+$E$1). The 1 means "the full price" and never changes; only the rate lives in a cell.=ROUND(C2,2)to round to 2 decimal places.
A simple test: if the number could be different next month, or someone might ask "where did that come from?", give it a cell. A VAT rate or a commission rate fails that test, even if it hasn't changed in years.
How to find hardcoded numbers in a sheet#
Excel has a few built-in tools that make hidden numbers visible.
- Show Formulas. Press **Ctrl+
** (the grave accent key, usually above Tab) on Windows or Mac, or go to **Formulas > Show Formulas**. Every cell shows its formula instead of its result, so=B20.04stands out next to=B2$E$1`. Press the shortcut again to switch back. - Trace Precedents. Select a formula cell and choose Formulas > Trace Precedents. Excel draws arrows from the cells the formula uses. If a formula clearly uses a rate but no arrow points to a rate cell, the rate is typed in. Remove Arrows sits right next to it.
- Go To Special > Constants. Select a column of results, then Home > Find & Select > Go To Special and choose Constants. Excel selects any cell that holds a typed value instead of a formula. This catches the other kind of hardcoding: a result someone overwrote with a number.
- Inconsistent formula warnings. When one formula in a column differs from its neighbours, such as Chloe's
=B4*0.04among=B2*0.045formulas, Excel's error checking often marks it with a small green triangle. Don't ignore those.
What a job test usually checks#
In a practical Excel test, the person marking your file can easily check for hardcoding: they change an input and see whether every result updates. If you typed 0.04 into your formulas, your answers only work for one scenario.
Things that tend to make a good impression:
- Inputs in their own labelled cells, separate from calculations.
- Formulas that point to those cells with
$locks or names. - No results typed over formulas, even "just to fix one row".
If the task gives you a rate or a target in a cell, always point to that cell. Typing its value into your formula gets the same number today and fails the moment the reviewer changes it. Our guide to cell references in Excel covers the basics if any of this is new.
Common mistakes with hardcoded numbers#
These are the patterns that cause the most trouble:
- Typing the rate into the formula "just for now". It rarely gets fixed later. Make the input cell first.
- Forgetting the $ on the input cell. The first row is right and the rest read empty cells and show 0.
- Hardcoding a percentage as a whole number.
=B2*4instead of=B2*4%or=B2*0.04multiplies by 4. In an input cell, type4%so the value is 0.04. - Pasting a value over one formula. One row now holds a typed number, so it won't update. Use Go To Special > Constants to find it.
- Burying adjustments in formulas.
=SUM(B2:B5)+250hides an adjustment nobody can see. Put the 250 in a labelled cell and add that instead.
Our recommendation#
Treat every number in a formula as a question: would anyone ever change this? If the answer is yes, or even maybe, move it to a labelled input cell and point to it with $E$1 or a name. If it's a fixed fact, like 12 months or the 1 in 1+rate, hardcoding it is fine.
Then check your work the way a reviewer would. Change an input and make sure every result moves. Press Ctrl+` and scan for stray numbers. It takes a minute and catches the mistakes that have no error message.
Practise it#
Do the commission exercise on this page, then fill it down in your head: every row should still read E1. To build the habit from the start, try your first formulas, where every formula points to cells rather than typed numbers. Then the relative vs absolute references lesson has you break a tax formula and fix it by locking the rate cell with $.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
The commission rate is in E1, not typed into the formula. In C2, work out Ana's commission as her sales times the rate. Lock the rate cell with $ so the formula still reads E1 when filled down.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | ||||||
| 3 | ||||||
| 4 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 8 |
Tip: Multiply the sales in B2 by the rate in E1. Press F4 (fn+F4 on a Mac) to turn E1 into $E$1.
Practise this in a lesson
Frequently asked questions
What does hardcoded mean in Excel?
A hardcoded value is a number typed directly into a formula, such as =B2*0.04, or a typed number sitting where a formula should be. It doesn't update when the assumption behind it changes.
Why is hardcoding bad in Excel?
The number is hidden inside the formula, so nobody can see the assumption, and changing it means editing every formula that uses it. Miss one and the sheet gives wrong results with no error message.
Is it ever OK to hardcode numbers in a formula?
Yes, for values that are fixed by definition: 12 months in a year, 7 days in a week, 24 hours in a day, or the 1 in =B2*(1+$E$1). If the number is a business assumption that someone might change, give it a cell.
How do I find hardcoded numbers in Excel?
Press Ctrl+` (on Windows and Mac) to show formulas instead of results and scan for typed numbers. Trace Precedents on the Formulas tab draws arrows to the cells a formula uses, so a formula with numbers but no arrows deserves a closer look.
Should I use a named range instead of $E$1?
A name such as CommissionRate makes formulas easier to read, like =B2*CommissionRate, and it never moves when you fill. Both are much better than a hardcoded number.