#REF! error in Excel: causes and how to fix it
Fix #REF! in Excel: deleted rows, columns and sheets, formulas copied off the edge, VLOOKUP/INDEX/OFFSET out of range, INDIRECT, broken names and links.
#REF! means "invalid reference": a formula points to a cell, range or sheet that no longer exists, or that never could exist. Most of the time you caused it a moment ago by deleting a row, a column or a worksheet that a formula depended on. Unlike other errors, #REF! often changes the formula itself: Excel replaces the lost address with the text #REF!, so =B2*C2 becomes =B2*#REF! and the original address is gone for good. That makes #REF! the error where speed matters most: undo straight away and you lose nothing. This page shows every common cause on a small sheet, how to repair or prevent it, and how to hunt down #REF! that hides in names, charts and formatting rules. The overview of all errors is in Formula errors: what each one means and how to fix it.
What #REF! means
A reference has to land on a real cell. Excel's sheet runs from A1 to XFD1048576, and every reference must stay inside it and point to a sheet that exists. #REF! appears when a referenced cell was deleted, when copying a relative formula would push a reference off the edge of the sheet, when a function such as INDEX, OFFSET or INDIRECT is asked for a position that does not exist, or when a link to another workbook or sheet cannot be resolved.
Ctrl+Z (Cmd+Z) immediately. Undo restores both the cells and the formulas. Once you save and close, the original addresses cannot be recovered.Cause 1: a column or row the formula used was deleted
An order sheet had Product, Qty, Price and Total, with =B2*C2 in the Total column. Someone deleted the Price column because "prices are in the system anyway". Total moved one column left and its formula lost one of its inputs:
| A | B | C | |
|---|---|---|---|
| 1 | Product | Qty | Total |
| 2 | Pens | 10 | #REF! |
| 3 | Paper | 4 |
After column C (Price) was deleted, the formula keeps Qty but its second reference is gone.
Result: #REF!
Fix. Undo if you can. If not, restore the data (from a backup or a previous version under File › Info › Version History for files on OneDrive or SharePoint) and rewrite the formula with the correct address. The formula bar shows exactly which parts are #REF!.
Prevent it: refer to ranges, not lists of cells
A formula that adds individual cells breaks when one of them is deleted. A formula that uses a range simply shrinks. Below, a quarterly sheet had columns Q1, Q2 and Q3; column Q2 was deleted.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Q1 | Q3 | Total |
| 2 | Ana | 1200 | 1500 | #REF! |
Was =B2+C2+D2; deleting Q2 left a hole.
Result: #REF!
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Q1 | Q3 | Total |
| 2 | Ana | 1200 | 1500 | 2700 |
Was =SUM(B2:D2); the range shrank to B2:C2 and still works: 1200 + 1500 = 2700.
Result: 2700
Excel tables with structured references (=[@Qty]*[@Price]) and XLOOKUP instead of VLOOKUP column numbers make sheets even more robust. Before deleting anything in a shared workbook, select it and use Formulas › Trace Dependents to see which formulas would break.
Cause 2: a worksheet was deleted
A summary sheet collects totals from monthly sheets. Delete the sheet named Jan and every formula pointing at it loses its sheet name:
Before: =Jan!B10 + Feb!B10
After: =#REF!B10 + Feb!B10Fix. Sheet deletion cannot be undone with Ctrl+Z. Restore the sheet from a backup or version history, or use Find and Replace to repair all formulas at once: find #REF!B10, replace with the correct reference. Before deleting a sheet, search for its name with Ctrl+F, Look in: Formulas, Within: Workbook to see what depends on it.
Cause 3: copying a formula past the edge of the sheet
Relative references move when a formula is copied. If the move would place a reference above row 1 or left of column A, Excel has nowhere to point and writes #REF!. Here C2 calculates the change from last month with =B2-B1. Copying it up into C1 asks for the row above row 1:
| A | B | C | |
|---|---|---|---|
| 1 | Jan | 100 | #REF! |
| 2 | Feb | 120 | 20 |
| 3 | Mar | 150 | 30 |
The copy of =B2-B1 moved up one row; B0 does not exist.
Result: #REF!
Fix. Delete the formula from the first row (January has no previous month), or start the column with a deliberate blank or text such as "n/a". When copying large blocks, check that the target area does not shift references off the sheet.
Cause 4: VLOOKUP or INDEX asks for a column or row that is not there
VLOOKUP's third argument counts columns within the table you gave it. Ask for column 4 of a 3-column range and you get #REF!. This often happens after the table range is changed but the column number is not.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Code | Product | Price | Find | Price | |
| 2 | P-101 | Keyboard | 25 | P-102 | #REF! | |
| 3 | P-102 | Mouse | 12 | |||
| 4 | P-103 | Monitor | 189 |
A2:C4 has only three columns.
Result: #REF!
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Code | Product | Price | Find | Price | |
| 2 | P-101 | Keyboard | 25 | P-102 | 12 | |
| 3 | P-102 | Mouse | 12 | |||
| 4 | P-103 | Monitor | 189 |
XLOOKUP names the return column directly, so there is no number to get wrong. =VLOOKUP(E2, A2:C4, 3, FALSE) also works.
Result: 12
INDEX behaves the same way: =INDEX(C2:C4, 5) asks for the fifth item of a three-item list and returns #REF!. HLOOKUP returns #REF! for a row number beyond the table. CHOOSECOLS and CHOOSEROWS return #VALUE! instead for out-of-range numbers.
Cause 5: OFFSET goes off the sheet
OFFSET builds a reference by moving from a starting cell. A three-month moving average uses the current month and the two above it. Copy it into the first data row and the start of the range lands above row 1:
| A | B | C | |
|---|---|---|---|
| 1 | Month | Sales | 3-mo avg |
| 2 | Jan | 100 | #REF! |
| 3 | Feb | 120 | |
| 4 | Mar | 150 | 123.3 |
| 5 | Apr | 130 | 133.3 |
From B2, two rows up is row 0. In C4 the same formula averages B2:B4 = 123.3 (shown to one decimal).
Result: #REF!
Fix. Start the formula in the first row that has enough history (C4 here), or guard it: =IF(COUNT($B$2:B2)<3, "", AVERAGE(OFFSET(B2, -2, 0, 3, 1))). Because OFFSET is volatile and fragile, a plain =AVERAGE(B2:B4) copied down is often the better design.
Cause 6: INDIRECT text that is not a valid reference
INDIRECT turns text into a reference. If the text names a sheet that does not exist, contains a typo, misses the quotes around a sheet name with spaces, or points at a closed workbook, the result is #REF!.
| A | B | |
|---|---|---|
| 1 | Sheet | Sales B5 |
| 2 | Febr | #REF! |
| 3 | Mar |
There is no sheet called "Febr"; the sheet is named "Feb".
Result: #REF!
Fix. Correct the name, and always wrap sheet names in apostrophes so names with spaces work: =INDIRECT("'"&A2&"'!B5"). Data validation with a list of the real sheet names prevents typos. INDIRECT cannot read closed workbooks at all; open the source file or switch to Power Query.
Cause 7: cut and paste over a referenced cell
If you cut a cell (Ctrl+X) and paste it on top of a cell that another formula refers to, the overwritten cell is treated as removed, and the formula that pointed at it shows #REF!. Copy-paste does not do this: it overwrites the value but keeps the reference. Fix: undo, or use copy and paste values instead of cut when you overwrite cells that feed formulas.
Watch out: a spill reference to a cell that no longer spills
In Microsoft 365, A2# means "the whole spilled result that starts in A2". If A2 no longer contains a dynamic array formula, for example because someone pasted values over it, you do not get #REF!. Tested in Excel 365: A2# quietly shrinks to the single cell A2, so the answer is wrong without any warning:
| A | B | C | |
|---|---|---|---|
| 1 | Team | Count | |
| 2 | Ana | 1 | |
| 3 | Ben | ||
| 4 | Chen |
A2:A4 used to be the spill of =SORT(...); now they are typed values, so A2# is only A2 and COUNTA returns 1.
Result: 1
Fix. Restore the spilling formula in A2, or use a normal range such as =COUNTA(A2:A4), which returns 3. Not an error, but worth knowing when a total suddenly drops.
Cause 9: broken links and named ranges
A named range whose cells were deleted shows =#REF! in Formulas › Name Manager and returns #REF! wherever it is used. Links to another workbook return #REF! when the sheet they point to has been renamed or removed in that file. Use Data › Workbook Links (called Edit Links in older versions) to change the source, and delete or repair broken names in the Name Manager.
How to find every #REF! in a workbook
- Go To Special. Press
F5orCtrl+G(the same on a Mac), click Special, choose Formulas and leave only Errors ticked, then OK. Excel selects every formula on the sheet that shows an error, of any kind. Give the selection a fill colour so the cells stay visible after you click away. - Find All. Press
Ctrl+F(Cmd+F), type#REF!, open Options, set Look in to Values, tick Match entire cell contents, set Within to Workbook and click Find All. The list at the bottom shows sheet, cell and formula for every hit;Ctrl+Ainside the list selects them all. - Error Checking. Formulas › Formula Auditing › Error Checking jumps from one error to the next and offers Show Calculation Steps, which opens Evaluate Formula on that cell so you can see the exact step that fails.
- Trace Error. Select an error cell and choose Formulas › Error Checking (the arrow beside it) › Trace Error. Red arrows lead back to the cell where the error started; blue arrows show the healthy inputs. Errors travel downstream, so fixing the first cell often clears dozens of others.
- Count them with a formula.
=COUNTIF(B2:B500, "#REF!")counts the cells in a range that show this error, and=SUMPRODUCT(--ISERROR(B2:B500))counts every kind of error. Put the count next to a report total as an early-warning light. - Search inside formulas. Because #REF! is written into the formula itself, search with Look in: Formulas for
#REF!. This also finds formulas whose result is currently hidden by IFERROR. - Name Manager. Open Formulas › Name Manager, click Filter › Names with Errors and fix or delete each one.
- Formatting rules, validation and charts. Conditional formatting rules (Home › Conditional Formatting › Manage Rules, show rules for This Worksheet), data validation lists and chart series (Select Data) can also contain #REF! and are not found by Go To Special.
When you should NOT hide #REF!
Practically never. A #REF! means the structure of the workbook is broken: a formula is reading nothing at all. Wrapping it in =IFERROR(..., 0) turns a broken model into one that looks correct and is wrong. This is the strongest argument against blanket IFERROR: a sheet that quietly converted #REF! to zero can pass every visual check while a whole department's figures are missing from the total. Catch the specific error you expect (IFNA for lookups, an IF test for zero divisors) and let #REF! stay loud.
Version notes
- #REF! exists in every version of Excel and in other spreadsheet programs.
- Spill references with
#(Cause 8) exist only in Microsoft 365, Excel 2021 and later. - Version History for recovering deleted data works for files saved to OneDrive or SharePoint; local files depend on AutoRecover and your own backups.
- Excel for the web also shows #REF! for some links to other workbooks that it cannot reach; open the file in the desktop app to update the links.
Check yourself
1. You deleted a column and a total now shows =B2+#REF!+D2. What is the fastest safe fix if you did it a moment ago?
Undo restores the column and the original formula.
2. Which formula survives deleting one of the columns it adds up?
A range shrinks when a column inside it is deleted; separate cell references break.
3. =VLOOKUP(E2, A2:C9, 4, FALSE) returns #REF!. Why?
The column number points outside the table; a missing value would give #N/A.
4. Where should you search to find #REF! inside formulas, even when IFERROR hides the result?
#REF! is written into the formula text, so searching formulas finds it.