Fixing #REF! Errors: How to Delete Rows Without Breaking Your Formulas

intermediate📗 Google Sheets2026-05-30| Google Sheets (All Browsers, ChromeOS, Mobile App)

Error Message

#REF! (This happened because you deleted a row or column that was used in a formula)
#google-sheets#formula#ref-error#spreadsheet

The Scenario

I was recently cleaning up a 500-row financial dashboard when a simple task turned into a mess. I deleted about 15 rows of "obsolete" vendor data from 2023, and suddenly, my entire summary table turned red. Every single total was replaced by the #REF! error.

When this happens, Google Sheets provides a very specific explanation:

#REF! (This happened because you deleted a row or column that was used in a formula)

Most formulas in Sheets use relative or absolute cell references, like A5 or $B$10. If you delete the physical row where those cells lived, the formula's target coordinate vanishes. Unlike moving data—where Sheets updates the reference automatically—a deletion is a hard break. The formula effectively loses its map.

The Debugging Process

If you just saw the error appear, your best friend is Ctrl + Z (Undo). If it's too late for that, here is how I track down the source of the breakage:

  • Inspect the wreckage: Click a broken cell. You will likely see =SUM(#REF!:#REF!). The original coordinates are gone, overwritten by the error tag.
  • Follow the trail: Use the "Show formulas" view (`Ctrl + ``) to see how many dependent cells were infected by the deletion.
  • Audit Named Ranges: Sometimes the deletion occurred inside a Named Range. Check Data > Named ranges to see if any ranges are highlighted in red.

The Solutions

You can patch the error manually, but the real fix is building formulas that survive row deletions.

Method 1: The INDEX Function (The Deletion-Proof Choice)

The INDEX function is the most reliable way to prevent this. Instead of pointing directly to a cell, you point to an entire range and specify a position. If you delete a row, the formula stays locked onto that position, regardless of which data moves into it.

Standard (Fragile) Formula:

=A5 * 0.1

Delete Row 5, and this formula breaks instantly.

Resilient (INDEX) Formula:

=INDEX(A:A, 5) * 0.1

By using this version, you are asking for the 5th item in Column A. If you delete the current Row 5, the old Row 6 moves up. The formula simply grabs the new data sitting in the 5th slot.

Method 2: Using INDIRECT for Hard-Coded Links

Use INDIRECT if you need to reference a specific coordinate—like a Tax Rate in cell B2—that must never change. This function treats text strings as cell addresses.

=INDIRECT("B2") + INDIRECT("C2")

Because "B2" is text, Google Sheets won't change it when you delete rows. It will always look at whatever data happens to be in B2 at that moment. Just use it sparingly; too many volatile functions can slow down a sheet with 10,000+ rows.

Method 3: The OFFSET Function

OFFSET works well when you want to reference a cell relative to a stable anchor, such as a header row that you know will never be deleted.

=OFFSET($A$1, 4, 0)

This starts at cell A1 and moves down exactly 4 rows. As long as your header at A1 stays put, the formula will always find the value in the 5th row of that column.

Method 4: Using ArrayFormula for Clean Slates

If you frequently import and delete data, individual row formulas are a liability. Try an ArrayFormula in the header row instead.

=ArrayFormula(IF(A2:A="", "", A2:A * 1.2))

Place this in cell B2. It calculates the entire column at once. If you delete row 100, the formula simply recalculates for the remaining data without losing its reference.

Verification Steps

After applying these fixes, test the sheet's durability with these steps:

  • Insert a test row: Add a row above your data. Does the formula still capture the correct value?
  • Delete a row: Remove a line of data. If you used INDEX or INDIRECT, the #REF! error should stay away.
  • Check the totals: Verify that your SUM ranges didn't shrink. For example, ensure SUM(A5:A10) didn't accidentally become SUM(A5:A9).

Lessons Learned

  • Stop "Point and Click" for volatile data: If your workflow involves deleting and pasting rows, stop clicking individual cells. Use INDEX(A:A, row_number) instead.
  • Lock your headers: Use Data > Protect sheets and ranges to lock your top rows. This prevents accidental deletions that break OFFSET or ARRAYFORMULA anchors.
  • Clear, don't delete: Whenever possible, use the Backspace or Delete key to clear cell contents. Deleting the actual row structure is what causes the most damage.

Related Error Notes