EARTHLOOMGuides   Apps

How to find and replace in Google Sheets with a preview

Blind find-and-replace in Google Sheets risks corrupting formulas, converting numbers to text, and scattering errors across thousands of cells. The safe workflow is to generate a preview sheet that shows every before-and-after value, approve or reject each row, apply only the approved changes in batches, and keep an undo log that can restore the original state even after the sheet closes.

Why this is harder than it looks

The built-in Find and Replace applies instantly with no preview, no per-row control, and no undo after you close the dialog. Add-ons that promise preview often skip formulas, mishandle regex capture groups, or time out on large ranges. Users cleaning imports, SKUs, URLs or translations need to see exactly what will change - including inside formulas - and revert single rows without a full sheet restore.

Step by step

  1. Define the exact search pattern and scope. Decide whether you need plain text, whole-word, case-sensitive, or regex with capture groups. Choose scope: current selection, one sheet, all sheets, or a specific A1 range (e.g., A2:Z5000). Exclude header rows. If using regex, test the pattern in a regex tester first - Sheets uses RE2 syntax. Write the replacement using $1, $2 for capture groups.
  2. Generate a preview sheet with highlighted matches. Run the search across the chosen scope. For each cell with a match, create a row in a new "Preview" sheet showing: sheet name, cell address, original value, new value with matches highlighted, and a checkbox defaulted to TRUE. Keep formulas and values separate - if a cell contains a formula, show both the formula text and its calculated result so you can decide whether to edit the formula or the output.
  3. Review and toggle rows you do not want changed. Scroll the preview. Uncheck rows where the replacement breaks a formula, creates a duplicate SKU, or changes a date/number into text. For regex, verify capture groups produced the expected rearrangement. Filter the preview by sheet or by "unchecked" to focus on problem areas. Do not apply until every row you intend to change is checked.
  4. Apply in contiguous batches to avoid timeouts. Group checked rows by sheet and by contiguous row ranges. Write each batch with a single Range.setValues call. This keeps the operation under the 30-second execution limit even for 500,000 cells. The tool should show a progress bar and skip any row that now fails validation (e.g., data validation rules).
  5. Keep an undo log for one-click restore. On apply, write a hidden "Undo Log" sheet recording: timestamp, sheet, range, original values array, and a run ID. Add a menu item "Undo last replace" that reads the latest run ID and writes the original values back in one batch. The log survives closing the sidebar; you can undo days later if no other edits touched those cells.
  6. Handle numbers, dates and formulas correctly. By default, skip cells formatted as number, date, currency, or percentage - replacing text inside them often converts them to plain text and breaks sorting. Add an opt-in checkbox "Include numbers/dates" with a warning. For formulas, offer two modes: edit the formula text (preserving =) or edit the displayed result (converts to static value). Default to formula-text mode.

Common mistakes

Where ReplacePreview fits in

ReplacePreview adds a sidebar in Google Sheets where you enter the search and replace terms, choose scope and options, and get a preview sheet with per-row checkboxes. It highlights matches, handles regex capture groups, skips numbers/dates unless you opt in, applies in batches up to 500k cells, and creates an undo log sheet. Free tier allows one plain-text rule and 500 cells per run; Pro adds regex, formulas, multi-rule batches and unlimited cells.

ReplacePreview support and FAQ

FAQ

Will replacing inside a formula break the formula?

If you edit formula text mode, the formula stays a formula - e.g., replacing "USD" with "EUR" in =A1*USD_RATE becomes =A1*EUR_RATE. If you edit result mode, the cell becomes a static number. Preview shows both so you choose.

Can I undo after closing the spreadsheet?

Yes. The undo log is written to a hidden sheet in the same file. Reopen the file, open ReplacePreview, and click "Undo last replace" to restore the original values for that run.

What happens if the replacement creates a formula error like #REF!?

The apply step validates each cell after write. Cells that error are skipped and reported in the summary. You can then fix the pattern and re-run on just those rows.