Excel library

How to Fix #REF! Error in Excel (And Prevent It)

You delete a single column or edit a lookup table, and your clean summary suddenly fills with #REF! errors. This error appears when a formula points to a cell, row, or column that no longer exists, and most broken formulas take less than a minute to repair. In this tutorial, I'll show you how to fix #REF! error in Excel and keep your formulas from breaking again.

Quick answer
  1. If you just deleted a row, column, or sheet, press Ctrl + Z (on Windows) to undo it right away.
  2. Otherwise, select the broken cell, check the formula bar, and replace #REF! with a valid range such as =SUM(B2:C2).
  3. For a broken VLOOKUP or INDEX formula, lower the column or row number so it fits inside your lookup range.

Start with Method 1 if your sheet broke right after deleting rows, columns, or cells.

What Is the #REF! Error in Excel?

The #REF! error stands for an invalid cell reference. Excel shows it whenever a formula points to a cell, range, or worksheet that was deleted, overwritten, or referenced outside its bounds. The most common causes are deleting referenced rows or columns, setting a column number that is too large in VLOOKUP, or asking INDEX for a row beyond the table.

Method 1: Replace Deleted References to Fix #REF! Error in Excel

Use this method when formulas break after deleting a row, column, or worksheet and you can no longer undo the change. If the deletion just happened, press Ctrl + Z on Windows first to restore both the cells and the formulas.

Our quarterly sales data originally had Item in column A, Q1 in column B, Q2 in column C, Q3 in column D, and Total in column E using =B2+C2+D2. After deleting column C, the remaining table sits in A1:D7 and every cell in D2:D7 shows #REF!.

Quarterly sales table in A1:D7 where cells D2:D7 display #REF! and the formula bar in D2 shows =B2+#REF!+C2
Deleting the Q2 column breaks the addition formulas in D2:D7 into #REF! errors.
  1. Select cell D2 and look at the formula bar to confirm it reads =B2+#REF!+C2.
  2. Click inside the formula bar and clear the broken formula.
  3. Type the SUM formula below to add the remaining columns.
  4. Press Enter to return 930 for Desk.
  5. Drag the fill handle from D2 down to D7 to repair the rest of the column.
fxFormula
=SUM(B2:C2)
Formula =SUM(B2:C2) in cell D2 returning 930 for Desk, with repaired totals 670 through 460 in D3:D7
Replacing the broken formula with =SUM(B2:C2) restores the totals in D2:D7.

When column C was deleted, Excel could no longer resolve the middle cell in =B2+C2+D2, so it replaced that missing address with #REF! and shifted D2 left into C2. Entering =SUM(B2:C2) replaces the broken addition chain with a valid range reference. Filling the formula down repairs all six items, returning 930 for Desk, 670 for Chair, 410 for Lamp, 540 for Shelf, 340 for Stand, and 460 for Tray.

Find all #REF! errors on a large worksheet

If your workbook has hundreds of rows, you can list every broken formula at once with Find and Replace. Press Ctrl + F on Windows, type #REF! in Find what, click Options, set Look in to Formulas, and click Find All. Searching in Formulas highlights cells that contain #REF! directly; switching Look in to Values also lists downstream formulas that inherited the error from another cell.

Note: Cutting a cell with Ctrl + X and pasting it directly over a referenced cell also causes #REF!, whereas copying and pasting only updates the value. See our guide on moving cells without changing formulas for safer ways to reorganize data.

Method 2: Fix the Column Index Number in VLOOKUP

Use this method when a VLOOKUP formula returns #REF! even though the formula text does not contain #REF!. This happens whenever the third argument, col_index_num, is larger than the number of columns in your lookup table.

Our data is in A1:C7 with three columns (Item, Q1, and Q3), the lookup item Lamp is in E2, and cell F2 currently holds =VLOOKUP(E2,A2:C7,4,FALSE) from before column Q2 was deleted.

  1. Select cell F2 to inspect the broken VLOOKUP formula in the formula bar.
  2. Count the columns inside your table array A2:C7 (column A is 1, column B is 2, and column C is 3).
  3. Change the column index number from 4 to 3 so it matches column C.
  4. Press Enter to return 230 for Lamp.
fxFormula
=VLOOKUP(E2,A2:C7,3,FALSE)
VLOOKUP formula =VLOOKUP(E2,A2:C7,3,FALSE) in cell F2 returning 230 for Lamp from A2:C7
Changing the column index number to 3 fixes the VLOOKUP formula and returns 230 for Lamp.

VLOOKUP counts columns starting from the leftmost column of its table_array. Asking for column 4 inside a three-column range (A2:C7) points past the right edge of the table, which triggers #REF!. Updating col_index_num to 3 tells Excel to return the value from column C on the Lamp row, which is 230.

Switch to XLOOKUP or INDEX and MATCH to avoid column-index errors

If your table layout changes often, replace VLOOKUP with XLOOKUP (available in Microsoft 365, Excel 2021, and Excel 2024). Because XLOOKUP selects the lookup column and return column separately, inserting or deleting columns between them will not break the formula.

fxFormula
=XLOOKUP(E2,A2:A7,C2:C7)

On older versions of Excel, an INDEX and MATCH formula gives the same protection: =INDEX(C2:C7,MATCH(E2,A2:A7,0)). Both formulas return 230 for Lamp without a hard-coded column number.

Note: In VLOOKUP, #REF! means your column index is larger than the table array, while #N/A means the lookup value was not found. If you are seeing #N/A instead, follow our guide to fixing the value not available error in Excel.

Method 3: Fix Out-of-Range Arguments in INDEX

Use this method when an INDEX formula returns #REF! because its row number or column number is larger than the range you gave it. This often happens after you trim rows from the bottom of a list or miscount the size of the array.

Our six-row table is in A1:C7 (data in A2:C7), and cell E2 currently has =INDEX(A2:C7,7,3), which returns #REF! because A2:C7 only contains six rows.

  1. Select cell E2 and review the range and coordinates in the formula bar.
  2. Check the dimensions of A2:C7: it has 6 rows (rows 2 through 7) and 3 columns (A through C).
  3. Replace the row number 7 with 3 to target the third data row (Lamp).
  4. Press Enter to return 230 from row 3, column 3 of the range.
fxFormula
=INDEX(A2:C7,3,3)
INDEX formula =INDEX(A2:C7,3,3) in cell E2 returning 230 from row 3 and column 3 of A2:C7
Keeping row_num within the 6-row table fixes INDEX and returns 230 for Lamp.

INDEX counts rows and columns starting at 1 from the top-left cell of the array, not from row 1 of the worksheet. Inside A2:C7, Desk is row 1, Chair is row 2, and Lamp is row 3. Asking for row 7 points outside the range and returns #REF!, while row 3 and column 3 correctly return 230.

Check INDIRECT links to closed workbooks

Another common source of #REF! with no deleted cells is the INDIRECT function. INDIRECT returns #REF! whenever it references another workbook that is currently closed, or whenever the text string inside it is not a valid cell address. Open the linked workbook to restore the value, or replace INDIRECT with a direct cell link so the formula still works when the source file is closed.

Note: The OFFSET function also returns #REF! if its row or column offset moves past row 1 or column A of the worksheet, such as =OFFSET(B2,-2,0).

Method 4: Use SUM Ranges and Clear Contents to Prevent #REF! Errors

Use this method when setting up new spreadsheets so future edits do not break your totals. Writing range-based formulas takes the same effort as chaining individual cells, and it survives column deletions cleanly.

Our full three-quarter dataset is in A1:E7, with Q1 in column B, Q2 in column C, Q3 in column D, and Total in column E.

  1. Select cell E2 under the Total header.
  2. Type the SUM range formula below instead of writing =B2+C2+D2.
  3. Press Enter to return 1410 for Desk.
  4. Drag the fill handle from E2 down through E7 to calculate every row.
fxFormula
=SUM(B2:D2)
Quarterly sales table in A1:E7 using =SUM(B2:D2) in cell E2 to return 1410 across Q1, Q2, and Q3
Using =SUM(B2:D2) instead of =B2+C2+D2 lets you delete an interior column without causing #REF!.

Because =SUM(B2:D2) points to a continuous range rather than three separate cells, Excel adjusts the endpoints automatically when you remove column C. The formula shrinks to =SUM(B2:C2) and recalculates to 930 instead of turning into #REF!. Across all six rows, the three-quarter totals are 1410, 1010, 620, 830, 510, and 710.

Four habits that prevent #REF! errors

  • Use Clear Contents instead of deleting cells: select the cells and press the Delete key (or go to Home > Clear > Clear Contents) when you only want to remove numbers. Formulas keep their references and treat blank cells as zero.
  • Use Excel Tables and structured references: press Ctrl + T to turn your data into a table and refer to columns by name instead of hard-coded coordinates.
  • Check dependents before deleting a row or column: select a cell, open the Formulas tab, and click Trace Dependents to see which formulas rely on it before you remove anything. If Excel warns you about broken links, see our guide on fixing formula reference problems in Excel.
  • Prefer XLOOKUP or INDEX and MATCH over VLOOKUP: avoiding hard-coded column numbers stops lookup formulas from breaking when columns are removed.

Note: Even with SUM, deleting the entire referenced range at once (columns B through D together) will still return #REF!. Clear contents instead if you plan to reuse those columns.

FAQs

Why does Excel show #REF! when I delete a row or column?

Excel displays #REF! because a formula directly referenced a cell inside the deleted row or column. Once that cell is removed from the grid, Excel replaces its address with #REF! inside the formula.

Can I undo a #REF! error after saving and closing the file?

No. Closing the workbook clears Excel's undo history, so Ctrl + Z will no longer restore deleted rows or columns. You must either rewrite the broken formula or restore an earlier copy from Version History if the file is saved in OneDrive or SharePoint.

Should I use IFERROR to fix #REF! errors in Excel?

No. Wrapping a formula in IFERROR hides the #REF! error behind a blank cell or message without fixing the broken reference, which can leave silent mistakes in your totals. Always repair the invalid cell reference first.

Why does my VLOOKUP formula return #REF! instead of #N/A?

VLOOKUP returns #REF! when the col_index_num argument is greater than the number of columns in your table_array. It returns #N/A when the lookup value cannot be found in the first column.

Why does INDIRECT return #REF! when linking to another workbook?

The INDIRECT function only works with external workbooks that are currently open in the same Excel session. Open the source workbook or switch to a direct cell reference so Excel can read the cached value while the file is closed.

Conclusion

When a #REF! error appears right after deleting cells or columns, undo with Ctrl + Z or replace the broken formula with a range formula like =SUM(B2:C2). For lookup errors, match your VLOOKUP column index or INDEX row number to the actual table size. Going forward, using SUM ranges, XLOOKUP, and Clear Contents instead of deleting cells is the approach I recommend for most spreadsheets because it prevents #REF! errors before they happen.