Sub topic 9
Named ranges as an alternative to absolute references
This chapter assumes you can enter and edit formulas, select ranges, and fill formulas down a column. It also assumes you already know how $ locks a row or column in a reference, as covered in the chapters on absolute and mixed references.
A defined name gives a cell or range a label such as TaxRate. You can then use the label in formulas instead of an address like $E$1. This chapter covers how names work, how they differ from absolute references, and where they cause problems.
Why consider names at all
Absolute references solve one problem: a fixed input stays fixed when you fill a formula. They have three weaknesses.
$E$1says nothing about what the cell holds. A reader has to go to E1 to find out.- You must remember to type the dollar signs, or press F4, every time.
- A formula that points to another sheet gets long, for example
=B2*Rates!$B$1.
A name fixes all three. Compare these two formulas:
D2: =B2*$E$1
D2: =B2*TaxRateBoth give the same result. The second one can be read without looking at the sheet.
Creating a name
You can define a name in three common ways.
- Name Box. Select the cell, click the Name Box (to the left of the formula bar), type
TaxRate, and press Enter. You must press Enter, or the name is not saved. - Define Name. On the Formulas tab, choose Define Name. This dialog lets you set the scope and add a comment.
- Create from Selection. Select a range that includes labels, such as a label in D1 next to a value in E1. Then choose Formulas, Create from Selection. Excel builds names from the labels.
After E1 is named TaxRate, this formula works in D2 and in every row you fill it down to:
D2: =B2*TaxRateNaming rules
Excel rejects names that break these rules.
| Rule | Valid example | Invalid example |
|---|---|---|
| Starts with a letter, underscore, or backslash | `TaxRate`, `_rate` | `2024Rate` |
| No spaces | `Tax_Rate`, `TaxRate` | `Tax Rate` |
| Not a cell address | `Rate1_2024` | `A1`, `R1C1`, `TAX2025` |
| At most 255 characters | `TaxRate` | A 300-character name |
| Case does not matter | `taxrate` equals `TaxRate` | Two names differing only by case |
The cell-address rule catches people most often. TAX2025 looks like a name, but it is also a valid cell address in the column TAX, row 2025, so Excel refuses it. Add an underscore or choose a different word, such as Tax_2025.
Why a name behaves like an absolute reference
A name refers to a fixed location. When you create a name through the Name Box, Excel stores the reference with dollar signs, as in =Sheet1!$E$1. You can see this in Formulas, Name Manager, in the Refers to column.
Because the stored reference is absolute, filling a formula that uses TaxRate never shifts it. That is why the name works in the fill-down example above.
The effect is the same as $E$1, but the lock is built into the name. You cannot forget a dollar sign in the formula.
A worked example
Suppose a sheet lists prices and applies a tax rate and a discount.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Item | Price | Tax rate | 0.08 |
| 2 | Pen | 2.50 | Discount | 0.10 |
| 3 | Book | 12.00 | ||
| 4 | Lamp | 30.00 |
Name D1 TaxRate and D2 Discount. Then the final price in column C, starting at row 3, is as follows. Here the rate cells sit in D1 and D2, so we use a separate column for output.
E2: =B2*(1-Discount)*(1+TaxRate)
E3: =B3*(1-Discount)*(1+TaxRate)
E4: =B4*(1-Discount)*(1+TaxRate)Only B2, B3, and B4 change as the formula is filled down. Discount and TaxRate stay where they are. The formula reads like the rule it implements.
The equivalent absolute version is =B2*(1-$D$2)*(1+$D$1). It works, but a reader must check D1 and D2 to learn which is which.
Names for ranges, not only single cells
A name can refer to a whole range. This is useful for a lookup table or for the range inside SUM.
Name B2:B10 as Sales. Then:
C2: =B2/SUM(Sales)The range inside SUM is fixed because the name is absolute. Compare this with the earlier formula =B2/SUM($B$2:$B$10). The result is the same.
Names also work for lookup tables. If A2:C50 is named PriceTable, you can write:
E2: =VLOOKUP(D2,PriceTable,3,FALSE)You no longer need to anchor the table with $A$2:$C$50.
Ranges that grow
A name that points to a fixed range does not grow when you add data at the bottom. There are two usual fixes.
- Excel tables. Convert the data to a table with Ctrl+T. Table columns get structured references such as
Sales[Amount], and these expand automatically as rows are added. - Dynamic formulas. A name can contain a formula. For example, a name
SalesListdefined as=Sheet1!$B$2:INDEX(Sheet1!$B:$B,COUNTA(Sheet1!$B:$B))grows with the data, as long as column B has no blank gaps and no header text counted in the count. Here the count includes a header in B1, so the range would end one row too far. Adjust by subtracting 1 or by starting the count below the header.
For most users, an Excel table is the simpler choice.
Scope: workbook or worksheet
Every name has a scope. The default is the whole workbook, meaning the name means the same thing on every sheet.
You can also limit a name to one worksheet. Then two sheets can each have their own TaxRate, pointing at different cells. A formula on each sheet uses its own.
Sheet "North", D2: =B2*TaxRate
Sheet "South", D2: =B2*TaxRateThe formulas look the same, but each uses the rate on its own sheet. This is useful when you copy a sheet to make a template for another region.
Scope has two traps.
- If a worksheet-scoped name and a workbook-scoped name share the same label, the worksheet one wins on its own sheet. This can be confusing, so avoid reusing a label unless you want that behaviour.
- When you copy a sheet that uses a workbook-scoped name, the copy still points at the original sheet's cell. If you want the copy to use its own cell, the name must have worksheet scope.
Check the Scope column in Name Manager when results look wrong.
How names behave under copy, move, and insert
The previous chapter covered what happens to references on copy, cut, insert, and delete. Names change the picture in a few ways.
| Action | Plain `$E$1` | Name `TaxRate` |
|---|---|---|
| Fill or copy the formula | Stays at `$E$1` | Stays at the named cell |
| Cut and paste the formula to another cell | Stays at `$E$1` | Stays at the named cell |
| Insert a row above E1 | Updates to `$E$2` | Name updates to the cell's new position |
| Delete the row containing E1 | `#REF!` | Name shows `#REF!` in Refers to, and formulas return `#REF!` |
| Cut and paste E1 elsewhere | Updates to the new cell | Name follows the moved cell |
| Copy and paste E1 elsewhere | Still points at the original E1 | Name still points at the original cell |
Two points deserve attention. The name follows the cell when the cell is moved or when rows are inserted, so formulas stay correct. If you delete the cell, though, the name is not removed. It stays in the Name Manager with a broken reference, and every formula that uses it shows #REF!.
Where names can mislead you
Names are not always better than $ references. Consider these cases.
Hidden inputs
A formula with $E$1 tells you where to look. A formula with TaxRate does not. In a large workbook, the reader must open Name Manager or press F5 and pick the name to jump to the cell. Put key inputs in a clearly labelled block and keep the name next to the label.
Mixed references have no name equivalent
A name always refers to one fixed place. You cannot build the multiplication table from earlier with names, because that formula depends on the column being locked and the row being relative:
B2: =$A2*B$1Mixed references are the right tool when part of the reference must move. Names are for fixed inputs.
Expanding ranges
A running total relies on one end of the range moving:
C2: =SUM($B$2:B2)A name cannot do that, because it would be fixed at both ends. Use mixed or partly anchored references here.
Names that outlive their purpose
Old names remain after the cells they pointed at are deleted or the layout changes. Open Name Manager occasionally and filter for names with errors.
Names and R1C1 or shared files
Names are stored with the workbook, so they travel with it. If you copy a formula to a different workbook, the name does not come with it. Excel may create a link back to the original workbook or add the name to the new one, depending on the scope. Check the result after pasting between files.
Debugging formulas that use names
When a result is wrong, work through these checks.
- Open Formulas, Name Manager and read the Refers to column for each name in the formula. Confirm it points to the cell you expect.
- Check the Scope column for duplicates of the same label.
- Select the formula cell and choose Formulas, Evaluate Formula. Step through to see the value Excel substitutes for each name.
- In a cell, type
=TaxRateand look at the result. If it shows#NAME?, the name does not exist or has a typo. If it shows#REF!, the cell was deleted. - To see all names and their targets in the sheet, choose Formulas, Use in Formula, Paste Names, then Paste List. Do this in an empty area, since it writes into cells.
A #NAME? error also appears when you misspell a function, so check for that if the name looks right.
Choosing between a name and `$`
| Situation | Better choice |
|---|---|
| A single input used in many formulas, such as a rate | Name |
| A lookup table used by several formulas | Name, or an Excel table |
| A one-off formula in a small sheet | `$` reference |
| Row or column must move with the fill | Mixed reference |
| Running total or growing range | Partly anchored range |
| A template copied to several sheets, each with its own input | Worksheet-scoped name |
| Collaborators who read formulas by clicking through cells | `$` reference, or names with clear documentation |
A diagram summarizes the decision.
Practical guidelines
- Name inputs, not intermediate results.
TaxRateis a good name.Temp1is not. - Use a consistent style, such as
TaxRateorTax_Rate, across the workbook. - Keep names short but meaningful. Avoid names like
xorRange1. - Keep the named cell next to a text label so the sheet itself explains the name.
- Prefer workbook scope unless you need separate copies per sheet.
- Review Name Manager before sharing a workbook, and delete names you no longer use.
Exercises
Exercise
A formula in D2 is =B2*TaxRate, and you fill it down to D20. TaxRate was created with the Name Box on cell E1. Why does every row still use E1, and what does Name Manager show in the Refers to column?
Show answer
A name created in the Name Box stores an absolute reference, so filling the formula does not shift it. Refers to shows =Sheet1!$E$1 (with your own sheet name). Only B2 is relative and changes to B3, B4, and so on.
Exercise
You try to name a cell TAX2025, and Excel rejects the name. Why, and what is a valid alternative?
Show answer
TAX2025 is a valid cell address (column TAX, row 2025), and names cannot look like cell addresses. Use a form that is not an address, such as Tax_2025 or TaxRate2025.
Exercise
Can you build the multiplication table =$A2*B$1 using only named ranges? Explain.
Show answer
No. A name refers to one fixed location, so it cannot lock only the column or only the row while the other part moves. This formula needs a mixed reference.
Exercise
You copy a sheet called North to make a sheet called South. Both use the workbook-scoped name TaxRate and the formula =B2*TaxRate. South should use its own rate in its own cell E1. What goes wrong, and how do you fix it?
Show answer
Both sheets still use the single workbook-level TaxRate, which points at the cell on North. To give South its own rate, define a worksheet-scoped name TaxRate on each sheet, each pointing at that sheet's E1, and remove or avoid the workbook-level name for this use.
Exercise
After deleting row 1 from a sheet, every formula using TaxRate returns #REF!. How do you find and fix the cause?
Show answer
Open Formulas, Name Manager. The Refers to column for TaxRate shows #REF! because the named cell was deleted. Put the rate in a new cell, select the name, choose Edit, and set Refers to the new cell. The formulas recover once the name points at a valid cell.