How to Fix the #REF! Error

#REF! means a formula refers to a cell that does not exist. It usually appears after a row, column or sheet was deleted, or when a lookup asks for a column outside its table. Describe what your formula should do below and get a version that does not break.

Free, no sign-up required · 5 free generations a day

Last updated

Describe your task, get the formula

Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.

Formulas that avoid #REF!

Syntax
=VLOOKUP(A2,$D$2:$F$100,3,FALSE)
=XLOOKUP(A2,$D$2:$D$100,$F$2:$F$100)
=SUM(INDIRECT("B2:B100"))

In VLOOKUP the column number must not be larger than the number of columns in the table range — a table of D to F has three. XLOOKUP points at the return column directly, so there is no column number to get wrong. INDIRECT builds the reference from text, so it survives deleted rows and columns, at the cost of being recalculated more often.

Examples

Keep the column number inside the table

=VLOOKUP(A2,$D$2:$F$100,3,FALSE)

The table has three columns, D, E and F, so 3 is the largest valid column number. Asking for column 4 returns #REF!.

Use XLOOKUP so there is no column number

=XLOOKUP(A2,$D$2:$D$100,$F$2:$F$100,"Not found")

The return range is its own argument. Inserting or deleting columns between D and F does not break the formula, because the references move with the data.

Refer to a sheet by the name in a cell

=INDIRECT("'"&A1&"'!B5")

Builds a reference to cell B5 on the sheet named in A1. If no sheet has that name, the result is #REF!, so check the spelling in A1 first.

Common mistakes and how to fix them

#REF! appears inside the formula after deleting a column

The original reference is gone and cannot be recovered from the formula. Press Ctrl+Z straight away, or retype the reference. To remove data without breaking formulas, clear the cells instead of deleting them.

#REF! after copying a formula to another place

A relative reference was pushed off the edge of the sheet, for example A1 moved one row up. Lock the reference with dollar signs before copying, or copy the formula text from the formula bar.

#REF! in Google Sheets on an array formula

Sheets shows #REF! when an array result cannot expand because cells in the way contain data. Clear the cells below and to the right of the formula.

Frequently asked questions

What does #REF! mean?

It means invalid reference. The formula points to a cell, range or sheet that was deleted or that never existed, so there is nothing to calculate from.

Can I find every #REF! error in a workbook?

Yes. Press Ctrl+F, search for #REF!, set Look in to Formulas and choose Find All. In Excel you can also use Go To Special, Formulas, Errors to select all error cells on a sheet.

Why does INDEX return #REF!?

The row or column number you asked for is larger than the range. INDEX(A2:A10,12) has only nine rows to choose from, so row 12 does not exist.

Don't want to write it by hand?

Describe what you need in plain English and get a ready-to-use formula in seconds.

Try the formula generator