Sub topic 8
Finding and replacing values
This chapter covers how Find and replace works in Google Sheets, which options change what it matches, and how to avoid damaging data with a broad replacement. It assumes you can already tell text, numbers, and dates apart, and that you know number formats change how a value is displayed without changing what is stored.
Two ways to search
Sheets has two search tools that look alike but do different jobs.
- Find bar (Ctrl+F, or Cmd+F on Mac). Opens a small search box in the sheet. It highlights matches and lets you step through them. It changes nothing.
- Find and replace dialog (Ctrl+H, or Cmd+Shift+H on Mac). Opens a dialog with search options and replacement buttons. You can also open it from Edit > Find and replace.
Browser shortcuts can interfere. If Ctrl+F opens the browser's own search, click inside the sheet first. You can also use the menu path.
The dialog options
The dialog has a Find field, a Replace with field, and a Search dropdown. Below those are several checkboxes.
| Option | What it does |
|---|---|
| Search: All sheets | Looks in every tab of the spreadsheet. |
| Search: This sheet | Looks only in the active tab. |
| Search: Specific range | Looks only in a range you enter, such as `B2:B100`. |
| Match case | Treats `Ann` and `ann` as different. |
| Match entire cell contents | Matches only cells whose whole content equals the search text. |
| Search using regular expressions | Reads the Find field as a pattern instead of literal text. |
| Also search within formulas | Searches the formula text, not just the displayed result. |
| Also search within links | Searches the URLs behind linked text. |
The buttons are Find (jump to the next match), Replace (change the current match only), Replace all (change every match in scope), and Done.
What Sheets searches: displayed values
By default, Find and replace searches what a cell displays, not what it stores. A cell that holds 1234.5 with the format $#,##0.00 displays $1,234.50. Searching for 1234.5 may not find it. Searching for $1,234.50 does.
This matters in three situations:
- Formatted numbers and dates. Search for the text you see on screen. A date shown as
27 Nov 2026is found by that text, not by its underlying serial number. - Formula cells. By default the search sees the formula's result. A cell containing
=B2*$E$1that displays42matches a search for42. The formula itself is not searched unless you turn on Also search within formulas. - Hidden rows and columns. Matches there can still be found. Check the scope before using Replace all, because you cannot see what will change.
Match entire cell contents
Without this option, the search text can match anywhere inside a cell. Searching for NY matches NY, Albany, and Sunny. With Match entire cell contents checked, only cells that contain exactly NY match.
Use it when you replace a whole code or label, such as changing the status N/A to Unknown. Leave it off when you replace a fragment, such as changing Street to St. inside longer addresses.
Regular expressions
A regular expression (regex) is a pattern that describes text. When you check Search using regular expressions, the Find field is read as a pattern. Sheets uses the RE2 syntax, which supports common features like character classes, anchors, and groups. It does not support lookahead or backreferences inside the pattern itself.
Useful patterns:
| Goal | Find | Replace with | Column |
|---|---|---|---|
| Remove leading and trailing spaces | `^\s+\ | \s+$` | (empty) |
| Collapse runs of spaces to one | ` {2,}` | one space | |
| Remove all digits | `\d` | (empty) | |
| Swap `Last, First` to `First Last` | `^(\w+), (\w+)$` | `$2 $1` | |
| Match blank cells | `^$` | the value to insert |
In the replacement field, $1, $2, and so on insert the text captured by the first, second, and later parenthesized groups. This lets you reorder pieces of a value without a formula.
The pattern ^\s+|\s+$ in the table is written with a backslash before the pipe only because the pipe also separates table columns. In the dialog, type ^\s+|\s+$ with no backslash before the pipe.
Regex search respects Match case. Without it, [a-z] also matches uppercase letters.
Formulas as an alternative
Find and replace changes the data in place. Sometimes you want to keep the original and produce a cleaned copy. A formula does that.
=SUBSTITUTE(A2,"Street","St.")SUBSTITUTE replaces literal text and is case-sensitive. For pattern-based changes, use REGEXREPLACE:
=REGEXREPLACE(A2,"\s+"," ")Fill the formula down, review the results, then copy the column and paste it back over the original with Paste special > Values only. This gives you a preview step that the dialog does not offer, and the source data stays intact until you choose to overwrite it. For trailing spaces alone, =TRIM(A2) is simpler than either.
Worked example: cleaning a status column
Suppose D2:D200 holds order statuses typed by several people: shipped, Shipped , SHIPPED, and ship.. You want all of them to read Shipped.
- Select
D2:D200first. The dialog then offers it as the specific range, which prevents changes elsewhere. - Open the dialog and set Search to Specific range with
D2:D200. - Check Search using regular expressions. Leave Match case off.
- In Find, enter
^\s*ship(ped|\.)?\s*$. In Replace with, enterShipped. - Press Find a few times to confirm the matches are what you expect.
- Press Replace all. Sheets reports how many cells it changed.
The count in that message is a check. If you expected about 40 changes and it reports 400, undo immediately with Ctrl+Z.
Gotchas and edge cases
- Replacement text is entered like typing. Replacing with
007or3/4may be parsed as a number or date, so the result can differ from what you typed. Check a few cells afterward, and apply a text format first if you need the literal characters. - Replace all is one undo step. Ctrl+Z reverses the whole operation, but only until you make other edits.
- Protected ranges and filtered views. Cells you cannot edit are skipped. Check the result count against your expectation.
- Empty Find field. With regex on, an empty or overly general pattern can match every cell. Always press Find before Replace all.
- Locale. Decimal and thousands separators follow your spreadsheet locale, so searching for
1,5versus1.5depends on the displayed format.
Exercise
A column shows prices formatted as $#,##0.00. A cell displays $1,234.50, and you search for 1234.5 with default options. Why might nothing match, and what should you search for instead?
Show answer
Find and replace searches the displayed text by default, and the cell displays $1,234.50, not the stored number 1234.5. Search for $1,234.50 (or a fragment such as 1,234) instead.
Exercise
You need to change every cell that contains exactly NY to New York in C2:C500, without altering Albany or Sunny. Which options do you set?
Show answer
Set Search to Specific range with C2:C500, and check Match entire cell contents. Optionally check Match case. Then press Find to confirm, and use Replace all.
Exercise
Names in A2:A100 are written Last, First. Give a regex Find pattern and a Replace with value that turn Smith, Ann into Ann Smith.
Show answer
Check Search using regular expressions. Find: ^(\w+), (\w+)$. Replace with: $2 $1.