Excel cannot guarantee that formulas will survive deleting the cells they refer to: those references can become #REF!. To avoid that, clear or hide rows instead of deleting them, or redesign formulas to find records by a stable ID; if a deletion has just happened, press Ctrl+Z on Windows to undo it.
What #REF! means in Excel
#REF! is Excel’s invalid-reference error. A formula contains a reference to a cell, range, worksheet, or other location that Excel can no longer identify. Deleting a row is one possible cause, but the error can also follow deletion of a column, a sheet, or cells used by a formula.
Not every deletion creates the error. Excel generally adjusts a reference when cells move because rows or columns are removed around them. For example, a formula pointing to a cell below a deleted row may be updated to point to that cell’s new address. The risk is greatest when the deleted cells are the actual cells a formula needs, or when a deletion removes the whole range or sheet the formula refers to. The result depends on the formula and what exactly was selected and deleted.
This distinction matters: a formula can remain syntactically valid while its meaning changes. A total may still calculate after a row is removed but no longer include the record you intended. Check important results after structural edits, not only for visible error messages.
How deleting rows affects references
Consider a worksheet where a formula in a summary area points directly to a value on a detail row. If you delete that detail row, Excel may replace the deleted target with #REF! in the formula. A formula that sums a larger range may instead have its range adjusted when an interior row is deleted. Deleting rows above or below a referenced range can also shift its address without breaking it.
Deleting a worksheet row is different from clearing its contents. Deleting removes cells and shifts or removes other cells; clearing contents leaves the cells in place but removes their values or formulas. A formula that still points to a cleared cell generally has a valid reference, although it may then return zero, a blank-looking result, or another value depending on the formula. That is often the safer choice when the worksheet’s layout and references should remain stable.
Also distinguish deleting a table record from deleting an entire worksheet row. Excel tables have their own row structure, and formulas using table column references often adapt as the table grows or shrinks. But a formula that points to a specific cell or a specific record can still lose its target when that record is removed.
Safer ways to remove unwanted records
Choose the action that matches what you mean by “remove.” If you only need to hide information from view, do not delete it. If you need to discard the values but preserve the worksheet’s structure, clear contents. If you need to permanently remove records, save a copy first and check formulas that rely on those records.
- Clear values but keep rows: Select the relevant cells or rows, then choose Home > Clear > Clear Contents. This leaves the cells in place, so direct references are less likely to become invalid. It does not preserve the data itself, so make a backup if you may need it.
- Hide rows: Select the row headers, right-click, and choose Hide. The data remains available to formulas, though a formula such as SUM normally includes hidden values unless you use a function or filtering approach designed to exclude them.
- Filter a table: Use the filter controls to show only the records you need to work with. Filtering changes what is displayed, not which records exist. Take care when selecting visible cells for a later operation so you do not unintentionally affect hidden records.
- Move records to an archive: Copy them to an archive sheet or workbook before removing them from the active list. Then check whether formulas refer to the original location. Moving or deleting the original records can still affect formulas that depended on those cells.
- Delete only after reviewing dependencies: Save a separate copy, identify formulas that refer to the rows, and verify key totals and reports after the change.
For a simple example, suppose a report uses a cell on row 12. If that record is no longer active but the report still needs its position to exist, clear the record’s contents rather than deleting worksheet row 12. If the objective is to remove the record from a dataset permanently, delete it only after deciding how the report should behave when that record is gone.
Use tables and stable record IDs
For lists that gain and lose records, an Excel table is usually easier to maintain than a collection of unrelated cell ranges. To create one, select the data and choose Insert > Table, or press Ctrl+T on Windows. Confirm whether the selection has headers. Table formulas can refer to columns by name, which is clearer than hard-coding a range that must be adjusted as the list changes.
For example, if a table is named Sales and has an Amount column, a total can refer to the column as a whole. With a table named Sales and amounts in its Amount column, use =SUM(Sales[Amount]). The formula totals the current values in that table column and normally adjusts as table rows are added or removed. That makes it suitable for a changing list, but it does not preserve a deleted sale: the total correctly stops including that record.
When a formula needs to retrieve a particular person’s or item’s value, use a stable ID rather than relying on a row number. With a table named Records containing unique IDs in ID and values in Amount, and the ID to find in E2, use =XLOOKUP(E2,Records[ID],Records[Amount],"Not found"). In Microsoft 365 for Windows, this returns the matching amount; if the ID has been removed, it returns “Not found” instead of a broken cell reference. XLOOKUP is available in Microsoft 365 and Excel 2021 or later. IDs should be unique if each lookup is meant to identify one record.
This approach changes the failure mode, not the business decision. If a deleted ID should still have a value in a historical report, retain an archive or a snapshot of the original data. A lookup cannot return a record that no longer exists in its source.
Why INDIRECT is usually not the fix
A common suggestion is to use INDIRECT to turn text into a cell reference. It may seem attractive because a text address is not the same as a normal direct reference, but it is not a dependable way to preserve the meaning of a deleted record. If a row is removed, a text address such as “A12” still describes a location, not the identity of the data that used to occupy that location. The cell now at that address may contain something else, or the intended value may be gone.
INDIRECT also makes formulas harder to audit because Excel cannot treat the text inside it like an ordinary visible reference when tracking dependencies. It is volatile, meaning it recalculates when Excel recalculates, which can add work in large models. Use it only when a formula genuinely needs to construct a reference from text, not as a general safeguard against deleting rows. A stable key, a table reference, or keeping the source record is usually a clearer solution.
Find and repair existing #REF! formulas
If the deletion has already occurred, first decide whether you can undo it. Ctrl+Z reverses the most recent action in Excel for Windows; on Mac, use Command+Z. Undo may not be available after closing the workbook or after other actions have changed the undo history. If the file is important, make a copy before attempting broader repairs.
To locate errors, use Find: press Ctrl+F on Windows or Command+F on Mac, search for #REF!, and, if needed, check the search options so Excel looks in formulas as well as displayed values. You can also review likely formulas directly and use the tools on the Formulas tab, including Error Checking and formula-auditing commands such as Trace Precedents and Trace Dependents. Ribbon labels and availability can vary somewhat by platform and update.
Repair the cause rather than merely hiding the message. If the formula should refer to a different cell, edit the reference. If it should retrieve a record, consider a lookup based on a unique ID. If the deleted value is needed for a historical calculation, restore it from a backup or archive. Wrapping a broken formula in IFERROR can conceal the error, but it does not restore the missing reference; do that only when a fallback result is genuinely appropriate.
A practical deletion-check workflow
Before removing rows from a workbook used for reporting, use a short review process. It helps prevent both visible errors and quieter changes to totals or results:
- Save a copy. Use File > Save As to create a recoverable version before a large or important edit.
- Clarify the goal. Decide whether you need to hide, clear, archive, or permanently delete the records. These actions have different effects on formulas.
- Review dependencies. Look for formulas, charts, summaries, and other sheets that refer to the affected data. Check whether references are direct cell addresses or table-based.
- Choose the least destructive action. Filter or hide records when they only need to disappear from view; clear contents when cell positions must remain; delete only when removing the data is intended.
- Check the workbook afterward. Search for
#REF!and compare key totals, counts, and reports with the expected result. A formula can change without showing an error.
Frequently Asked Questions
Can I stop Excel from ever showing #REF! when I delete a row?
There is no general setting that makes every formula safe from deletion. Keep referenced cells in place, use tables and stable IDs where appropriate, and review dependent formulas before deleting source data.
Is clearing a row safer than deleting it?
Usually, if your goal is to remove the contents while keeping the worksheet structure. Use Home > Clear > Clear Contents. The formulas can still refer to those cells, but their results may change because the cells are now empty.
Why did Excel change my formula instead of showing #REF!?
Excel often adjusts references when cells shift after a deletion. A changed reference can remain valid but point to a different range or include different data. Verify the formula’s meaning and its result, not just whether an error appears.
Will converting my data to a table prevent broken references?
Tables make many formulas easier to maintain as records are added or removed, especially formulas that refer to whole columns by name. They do not guarantee that every formula survives deletion, and they cannot retain a record that you have removed.
Can IFERROR fix a #REF! error?
IFERROR can display a chosen fallback instead of an error, but it does not repair the invalid reference or recover missing data. Fix the reference or restore the source when the original value is still needed.
Choose a method that matches the data’s purpose
The safest response depends on why the rows are being removed. For temporary cleanup, hide or filter. To keep formulas anchored to the same cells, clear contents rather than deleting rows. For a changing dataset, use an Excel table and refer to records through stable IDs where appropriate. For permanent deletion, keep a backup and validate dependent formulas and results afterward. Excel can adjust many references automatically, but it cannot infer whether a deleted record should disappear from a report or remain part of its history.
Related
- Open Excel Solver Add-in: Enable and Use It
- Open a Corrupted Excel File Online Safely
- Can You Open a Corrupted Excel File Online for Free?
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Errors & fixes
- Excel Not Working in QuickBooks Desktop? How to Fix ItIf Excel is not working in QuickBooks Desktop, first confirm that the desktop version of Excel is installed…
- Excel Not Filling Sequential Numbers? Fix the SeriesIf Excel repeats a number instead of counting, enter the first two numbers, select both cells, and drag…
- Excel Formula Not Calculating? Fix the Common CausesIf an Excel formula is not calculating, first check Formulas > Calculation Options > Automatic, then check whether…
- Excel Column Height: AutoFit Rows and Fix Wrapped TextExcel does not have a separate column-height setting: columns have width, while rows have height. To make text…
- Excel INDEX MATCH Not Working With Numbers?Yes—INDEX/MATCH can return the wrong result or #N/A when a lookup number is stored as text, when the…
- XLOOKUP Not Working? Check These Format IssuesYes—differences in the underlying data type or characters can make XLOOKUP return no match, even when two cells…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.