Sub topic 10
Fixing #REF!, #NAME?, and #DIV/0! Errors
This chapter assumes you can enter values, write formulas that start with =, and tell relative, absolute, and mixed references apart. It also assumes you have used ranges such as B2:B10 and references to other sheets. Here you learn what three common errors mean, what usually causes them in reference-heavy work, and how to fix each one.
How Sheets reports a formula problem
When a formula cannot produce a value, Sheets shows an error code in the cell instead of a result. The code tells you the category of the problem. It does not tell you which part of the formula is at fault, so you still have to look.
Two habits make diagnosis faster:
- Click the cell and read the formula in the formula bar. Sheets colors each reference in the formula and outlines the matching cells, so you can see what the formula points at.
- Hover over the red triangle in the corner of the cell. Sheets shows a short message that names the error and often hints at the cause.
The table summarizes the three errors in this chapter.
| Error | Meaning | Typical reference-related cause |
|---|---|---|
| `#REF!` | The formula points at a location that does not exist or cannot be read | A referenced row, column, or sheet was deleted, or a copied formula moved off the grid |
| `#NAME?` | Sheets does not recognize a word in the formula | A misspelled function, a deleted or misspelled named range, or an unquoted sheet name or text value |
| `#DIV/0!` | The formula divides by zero or by an empty cell | A divisor cell is blank or zero, often because a locked reference points at the wrong cell |
Fixing #REF!
#REF! means "reference problem." The formula refers to something that is no longer there, or to a place that is not valid.
Cause 1: you deleted what a formula pointed at
Suppose D2 contains =B2*C2. If you delete column C, the formula has lost one of its inputs. Sheets cannot guess a replacement, so D2 becomes:
=B2*#REF!The same thing happens when you delete a whole sheet that other formulas read from. A formula such as ='Sales Data'!B2 shows #REF! after the sheet Sales Data is deleted.
Ranges behave differently from single cells. If you delete a row inside B2:B10, the range shrinks to B2:B9 and the formula keeps working. Only when you delete every cell the range covers does it turn into #REF!.
How to fix it:
- Press Ctrl+Z (Cmd+Z on Mac) right after the deletion if it was a mistake. This restores the formulas as well as the data.
- If the deletion was intended, click the broken cell and replace
#REF!in the formula with the correct reference. - Use Edit > Find and replace, choose "Search using regular expressions" off, set "Search in" to "All sheets" and tick "Also search within formulas", then search for
#REF!to find every broken formula at once.
Cause 2: a formula copied off the edge of the grid
A relative reference moves with the formula. If a formula in B2 is =A1 and you copy it to a cell that would need row 0 or column 0, there is no such cell, so the result is #REF!. This happens most often with references that point up or to the left of the formula and are copied toward the top or left edge.
Pinning the reference with $ is the usual remedy when the formula should always read the same cell.
Cause 3: a range with mismatched sizes or a blocked output
Some #REF! errors come from the output side rather than the input side. An array result needs empty cells to spill into. If a formula such as =ARRAYFORMULA(B2:B*C2:C) is placed above cells that already hold data, Sheets shows #REF! and a message that the result was not expanded because it would overwrite data. Clear the blocking cells or move the formula.
Cause 4: IMPORTRANGE without permission
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/SPREADSHEET_ID","Sheet1!A1:C10") shows #REF! the first time you use it, with a prompt to allow access. Hover over the cell and choose "Allow access." The error clears once the link is approved. If it stays, check that the spreadsheet URL is correct and that you can open that spreadsheet.
Cause 5: INDIRECT builds an invalid address
=INDIRECT("'"&A1&"'!B2") builds a reference from the text in A1. If A1 holds a sheet name that does not exist, or a typo, the built reference is invalid and the result is #REF!. Check the exact sheet name, including spaces and capitals.
Fixing #NAME?
#NAME? means Sheets met a word it cannot match to a function, a named range, or a valid piece of syntax.
Cause 1: a misspelled function
=SUMM(B2:B10)SUMM is not a function, so the cell shows #NAME?. Correct it to =SUM(B2:B10). As you type, Sheets suggests function names, so accepting a suggestion avoids most typos.
Cause 2: a named range that is misspelled or gone
If you defined a named range called TaxRate and then write:
=B2*TaxRateeSheets sees an unknown name and returns #NAME?. The same error appears if someone deletes or renames TaxRate in Data > Named ranges while formulas still use the old name. Open the Named ranges panel, compare the spelling, and either fix the formula or restore the name.
Cause 3: text that is not in quotes
Text inside a formula must be wrapped in double quotes. Without quotes, Sheets reads the text as a name.
=IF(B2>100, High, "Low")Here High has no quotes, so Sheets looks for a named range called High and fails. The fixed formula is:
=IF(B2>100, "High", "Low")Cause 4: a sheet name with spaces and no quotes
A sheet name that contains a space needs single quotes around it. This works:
='Sales Data'!B2This does not:
=Sales Data!B2Sheets reads Sales and Data as separate words and cannot interpret them. Add the single quotes, or rename the sheet to a single word such as SalesData, which needs no quotes.
Cause 5: a range typed with the wrong punctuation
A range uses a colon: B2:B10. A formula like =SUM(B2-B10) is valid and subtracts two cells, which gives a number but the wrong one. A formula like =SUM(B2:B10 with a missing parenthesis is a parse error instead. When you mean a range, check that you used :, not - or ;.
A quick check for #NAME?
Click the cell and look at the formula text. Any word that Sheets does not color as a function or a reference is a suspect. Ask three questions about it: is it a real function, is it a named range that exists right now, and should it have been in quotes?
Fixing #DIV/0!
#DIV/0! means the formula divided by zero. Sheets treats an empty cell as zero in arithmetic, so dividing by a blank cell also produces this error.
Cause 1: a divisor that is blank or zero
Suppose C2 holds a quantity and D2 contains =B2/C2. If C2 is empty or 0, D2 shows #DIV/0!. This is often legitimate. The data is simply not entered yet. In that case the fix is either to enter the value or to handle the empty case in the formula.
Cause 2: a reference that drifted
References can cause this error without any empty data in sight. Say you want every row to divide by a total stored in F1, and you write =B2/F1 in D2 and fill down. In D3 the formula becomes =B3/F2. F2 is empty, so D3 shows #DIV/0!. The cause is a relative reference that should have been absolute. The fix is to lock the divisor:
=B2/$F$1Now filling down keeps the divisor on F1 in every row. This is the most common reference-related source of #DIV/0!, and it is worth checking whenever the error appears from row 3 downward but not in the first row.
Cause 3: an average or ratio over an empty range
=AVERAGE(B2:B10) returns #DIV/0! when no cell in the range holds a number, because the average divides a sum by a count of zero. The same applies to formulas such as =SUM(B2:B10)/COUNT(C2:C10) when column C has no numbers.
Handling expected zero divisors
When a blank divisor is normal, for example in rows that are not filled in yet, you can guard the formula with IF:
=IF(C2=0, "", B2/C2)This returns an empty string when C2 is zero or blank, and the division otherwise. The same idea works over a whole column with ARRAYFORMULA:
=ARRAYFORMULA(IF(C2:C=0, "", B2:B/C2:C))You can also use IFERROR:
=IFERROR(B2/C2, "")Be careful with IFERROR. It hides every error, not just #DIV/0!. If a #REF! or #NAME? appears inside the formula later, IFERROR will mask it and you may not notice the formula is broken. Prefer the explicit IF test when you only expect a zero divisor, and use IFERROR when you really mean "show a blank on any failure."
A working method for any reference error
A short routine works for all three errors.
- Click the cell and read the formula in the formula bar.
- Identify the error type and recall the causes above.
- Look at the colored outlines. Does each outline sit on the cell you intended?
- Check the first cell where the error appears. Errors often spread, because a formula that reads an error cell returns that error too. Fixing the first one clears the rest.
- Re-fill the corrected formula down or across, then confirm one or two results by hand.
The diagram shows how to choose a path from the error code.
Common mistakes when fixing errors
- Wrapping a broken formula in
IFERRORbefore finding the cause. The formula still does not work, and now you cannot see that. - Typing over
#REF!with a plain value. The cell looks right but no longer updates. - Fixing only the first row and forgetting to fill the corrected formula down.
- Renaming a sheet or a named range without checking which formulas depend on it.
Exercises
Exercise
D2 contains =B2/F1, where F1 holds a total of 500. You fill the formula down to D3 and D3 shows #DIV/0!. What went wrong, and what is the corrected formula in D2?
Show answer
The reference F1 is relative, so in D3 it became F2, which is empty and counts as zero. Lock the divisor with =B2/$F$1 in D2 and fill down again.
Exercise
A cell shows #NAME? for the formula =IF(B2>100, High, "Low"). Why, and how do you fix it?
Show answer
High is not in double quotes, so Sheets treats it as a name that does not exist. Write =IF(B2>100, "High", "Low").
Exercise
You delete column C, and a formula that was =B2*C2 now reads =B2*#REF!. Name two ways to recover.
Show answer
Undo the deletion with Ctrl+Z or Cmd+Z, which restores the original formula. Or replace #REF! in the formula with the correct cell reference, and fill the fix down the column.