The #REF! error in Excel: what it means and how to fix it
#REF! means a formula points at a cell that isn't there any more. The most common cause is deleting a row or column that a formula used. Undo the delete straight away with Ctrl+
Causes and fixes at a glance
| What you see | Why | Fix |
|---|---|---|
=B2*#REF! in the formula bar | A row or column the formula used was deleted | Undo the delete, or type the right cell in place of #REF! |
| #REF! from VLOOKUP | The column number is bigger than the table | Widen the table, or count the columns again |
| #REF! from INDEX | The row number is past the end of the range | Check the number, or the MATCH that gives it |
| #REF! after copying a formula | It now points above row 1 or left of column A | Paste it where there's room, or lock the cell with $ |
=#REF!B5 where a sheet name was | The sheet it used was deleted | Close without saving if you can, or point at the right sheet |
Each one is worked through below.
A deleted row or column
An order sheet works out each line's total as the quantity times the price. D2 holds =B2*C2: 4 folders at £1.20 each is 4 × £1.20 = £4.80.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Qty | Price | Total |
| 2 | Folders | 4 | £1.20 | £4.80 |
| 3 | Labels | 2 | £3.75 | £7.50 |
| 4 | Pens | 10 | £2.50 | £25.00 |
Then someone deletes column C to tidy the sheet. The prices have gone, so Excel can't point at them any more, and the Total column moves left into C. Its formula becomes =B2*#REF!, and the answer is #REF!:
| A | B | C | |
|---|---|---|---|
| 1 | Item | Qty | Total |
| 2 | Folders | 4 | #REF! |
| 3 | Labels | 2 | #REF! |
| 4 | Pens | 10 | #REF! |
If you've only just deleted it, undo: Ctrl+
Ranges cope better than single cells
A range shrinks when you delete a row inside it. A list of cells added one by one can't, so it breaks. Here row 3 (Labels, £7.50) was deleted from a list of four amounts:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | Amount | With SUM | With + | |
| 2 | Folders | £4.80 | £32.50 | #REF! | |
| 3 | Pens | £25.00 | |||
| 4 | Staples | £2.70 |
The SUM gives £32.50, the total of the three amounts left. The formula that added cells one by one has lost one of them, so it shows #REF!. Use ranges, such as =SUM(B2:B10), wherever you can.
VLOOKUP's column number is too big
=VLOOKUP(A2,$E$2:$F$5,3,FALSE) asks for the 3rd column of a range that only has 2 (E and F). Count the columns in the range, starting with the first one as 1, or make the range wider.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Code | Price | Code | Name | Price | ||
| 2 | P-02 | £1.20 | P-01 | Pens | £2.50 | ||
| 3 | P-03 | #REF! | P-02 | Folders | £1.20 | ||
| 4 | P-03 | Labels | £3.75 | ||||
| 5 | P-04 | Staples | £0.90 |
This often happens when a column is deleted from the lookup table: the table gets narrower, but the column number in the formula stays the same. XLOOKUP avoids it, because you point at the column to bring back rather than counting. There's more in VLOOKUP: a simple worked example.
INDEX past the end of its range
INDEX brings back the item at a position: =INDEX($B$2:$B$5,2) is the 2nd item in B2:B5. B2:B5 holds 4 items, so asking for the 5th gives #REF!.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | Price | Position | INDEX | |
| 2 | Pens | £2.50 | 2 | £1.20 | |
| 3 | Folders | £1.20 | 4 | £0.90 | |
| 4 | Labels | £3.75 | 5 | #REF! | |
| 5 | Staples | £0.90 |
With INDEX and MATCH, check that the range in INDEX covers the same rows as the range in MATCH. If MATCH searches A2:A10 and INDEX only has B2:B5, a match in row 8 is past the end.
Copied off the edge
A formula in row 2 that points at the row above, =B1-B2, works. Copy it up to row 1, and it would need row 0, which doesn't exist, so it becomes #REF!. Copying a formula left can do the same at column A. Paste it where there's room, or lock the cell it must always use with $, such as $B$1, so copying doesn't move it (see absolute references).
Another sheet was deleted
A summary sheet that picks up totals from monthly sheets shows #REF! for any month whose sheet has gone. Here the March sheet is there, but the April sheet was deleted. B3 used to hold =April!B5; once the sheet is gone, Excel rewrites it as =#REF!B5, so the sheet's name is lost too:
| A | B | |
|---|---|---|
| 1 | Month | Total |
| 2 | March | £1,425.00 |
| 3 | April | #REF! |
Excel can't undo deleting a sheet. If you haven't saved since, close the file without saving and open it again, and the sheet is back. Otherwise, type the right sheet name in place of #REF!, such as =May!B5. Formulas that point at a sheet in another workbook show #REF! in the same way if that sheet is deleted. See VLOOKUP from another sheet for formulas across sheets.
Finding them, and stopping them
- Find every one. Press Ctrl+F (Cmd+F on a Mac) and search for
#REF!. Find looks inside formulas, so it finds every formula that has lost a cell, even one whose answer looks fine. - Check before deleting. Click a cell in the column, then Formulas › Trace Dependents, which is on the Formulas tab in Excel for Mac too. Arrows point to every formula that uses it. Remove Arrows clears them. See formula auditing for the other checking tools.
- Use ranges, like
SUM(B2:B10), rather than adding cells one by one. - Use XLOOKUP, which points at the column to bring back rather than counting.
Hiding #REF! with IFERROR is rarely right: it always means something is broken. For other errors, see #N/A, #NAME? and #DIV/0!.
Try it now
Someone wrote =VLOOKUP(A2,$F$2:$G$5,3,FALSE) here and got #REF!. In C2, fix the VLOOKUP so it gives the price from the table in F2:H5. Your formula will be copied down to C5.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Code | Qty | Price | Code | Name | Price | ||
| 2 | P-02 | 4 | P-01 | Pens | £2.50 | |||
| 3 | P-03 | 2 | P-02 | Folders | £1.20 | |||
| 4 | P-01 | 10 | P-03 | Labels | £3.75 | |||
| 5 | P-04 | 3 | P-04 | Staples | £0.90 |
Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.
Part of Excel data analysis practice: every lesson on the topic, with a project in Excel.
Where it works
#REF! and every fix here are the same in every version of Excel, on Windows and Mac, and in Excel for the web. XLOOKUP needs Excel for Microsoft 365, or Excel 2021 or later.
Questions
What does #REF! mean in Excel?
It means a formula refers to a cell that no longer exists. Usually a row, column or sheet that the formula used has been deleted, so Excel replaces that part of the formula with #REF!. It also appears when VLOOKUP asks for a column past the edge of its table, when INDEX asks for a position past the end of its range, or when a formula is copied off the edge of the sheet.
How do I fix #REF! after deleting a column?
If you've only just deleted it, undo with Ctrl+Z, or Cmd+Z on a Mac, and the formulas come back as they were. Otherwise, click a cell showing the error and look in the formula bar: the #REF! inside the formula marks the reference that was lost. Type the right cell or range in its place, then copy the fixed formula down the column.
Why does VLOOKUP give #REF!?
The column number is bigger than the number of columns in the table. =VLOOKUP(A2,$E$2:$F$9,3,FALSE) asks for the 3rd column, but E to F is only 2 columns. Count the columns from the first one in the table as 1, or widen the table to take in the column you want. This often happens after a column is deleted from the table.
How do I find all #REF! errors in Excel?
Open Find with Ctrl+F, or Cmd+F on a Mac, type #REF! and choose Find All. Find searches inside formulas, so it lists every formula that has lost a cell, including ones whose answer doesn't show an error yet. To find every cell showing any error, use Go To, then Special, then Formulas with only Errors ticked.