Formula Errors

How to Fix the #REF! Error in Excel

Fix the #REF! error in Excel by finding the deleted cell, sheet, or broken reference a formula points to, then repointing the formula at valid cells.

On this page
  1. Undo a recent delete
  2. Point the formula at the right cells
  3. Lookups with a column number that’s too large
  4. INDIRECT and OFFSET
  5. Deleted sheets and moved files
  6. Find every #REF! in a workbook
  7. Prevent it next time
  8. Google Sheets

The #REF! error means a formula points to a cell, range or sheet that Excel can’t find. Deleting something the formula depends on is the most common cause. A lookup with a column number that’s too large, or a broken link to another file, can cause it too.

Undo a recent delete

If you’ve just deleted a row, column or cell that a formula uses, press Ctrl+Z (Command+Z on a Mac) to bring it back. Deleting the referenced cells is what turns a reference into #REF!. For example, if D2 contains =B2*C2 and you delete column C, the formula changes to =B2*#REF!.

Point the formula at the right cells

If the cells are really gone, change the formula. Click the cell, press F2 to edit it, and point the reference at the correct cells. If the data still exists somewhere else in the workbook, point the formula there.

Lookups with a column number that’s too large

VLOOKUP and INDEX return #REF! when the number points outside the range they’ve been given. For example, =VLOOKUP(A2,D2:F20,5,FALSE) returns #REF! because the range D:F has only three columns. The column number counts from the first column of the range, not from the column letter on the sheet.

To fix it, count the columns from the first column of the range and set the number to match the column you want.

INDIRECT and OFFSET

  • INDIRECT turns text into a reference. If the text names a sheet or cell that doesn’t exist, the result is #REF!. A typo in the sheet name is a common cause.
  • OFFSET returns #REF! when its offset moves the reference off the worksheet, such as above row 1 or to the left of column A.

Check the text inside INDIRECT for spelling and quotation marks, and check the row and column offsets in OFFSET.

Deleted sheets and moved files

  • Deleted sheets. A formula that refers to a sheet that has been deleted shows #REF!.
  • Other workbooks. A formula that points at another file can show #REF! when that file has been moved, renamed or changed. For the common reasons, see why do links to other workbooks break in excel.

To point an existing link at the right file, open Edit Links from the Data tab and change the source.

Find every #REF! in a workbook

Press Ctrl+F, type #REF!, and search the sheet or the whole workbook. Excel should find cells that display that error. Error Checking on the Formulas tab can also help you locate formulas that need attention.

Prevent it next time

  • Use Clear Contents (press Delete) when you only want to empty a cell. Deleting cells, rows or columns changes the references in every formula that uses them.
  • Use named ranges so formulas are easier to read. How to create named range in excel explains the steps. A named range still needs to point at real cells, but it makes the formula’s purpose clearer.

Google Sheets

Google Sheets shows #REF! too, but usually for different reasons. Two common ones are an IMPORTRANGE formula that hasn’t been given access to the other spreadsheet, and an ARRAYFORMULA result that would overwrite existing data. The setup steps for IMPORTRANGE are in importrange google sheets how to use.

Fix the reference first, then check the formulas that depend on it.

The complete guide to formula errors

Excel Formula Error Messages Explained
Read the guide

Keep exploring

Guides from other topics

All topics →