Sub topic 15
Editing many cells with Find and Replace
This chapter assumes you can select cells, enter and edit a cell's contents, and tell text from numbers. It also assumes you know that a cell holds a stored value that may display differently. Find and Replace changes many cells in one operation. It works on what you could edit by hand, so the stored-versus-displayed distinction matters here.
Opening the dialog
Press Ctrl+F to open Find and Ctrl+H to open Replace. Both open the same dialog with two tabs. On the Home tab you can also choose Find & Select, then Find or Replace.
Click Options to expand the dialog. The options decide what Excel searches, so most surprises come from them.
| Option | What it controls | Default |
|---|---|---|
| Within | Search the current Sheet or the whole Workbook | Sheet |
| Search | Read by Rows or by Columns | By Rows |
| Look in | Formulas, Values, Notes, or Comments | Formulas |
| Match case | Treat "Art" and "art" as different | Off |
| Match entire cell contents | Match only cells that equal the search text exactly | Off |
| Format | Match or apply a cell format | None |
If you select a range before opening the dialog, Excel searches only that range. If you select a single cell, it searches the whole sheet, or the workbook if Within is set to Workbook. Selecting a range first is the safest habit, because it limits the damage if a replacement is wrong.
Find versus Replace
Find All lists every match in a table at the bottom of the dialog, with its sheet, cell address, value, and formula. Click a row in the list to jump to that cell. Click one entry, then press Ctrl+A inside the list to select every matching cell on the sheet. You can then close the dialog and apply formatting to all of them at once.
Replace has two buttons that behave differently:
- Replace changes the current match and moves to the next one. Use it when you want to review each change.
- Replace All changes every match in the search scope at once. Excel then reports how many replacements it made.
Use Find All first to see what will change, then Replace All only when the list looks right.
A worked example
Suppose column A holds product codes entered inconsistently:
| A |
|---|
| north-001 |
| North-002 |
| NORTH-003 |
| south-004 |
Select A1:A4, press Ctrl+H, and set Find what to north and Replace with to Region1. With Match case off, all three north entries match, whatever their capitalization. The results are Region1-001, Region1-002, and Region1-003. The south-004 cell is unchanged.
With Match case on, only north-001 matches, because the other two use different capitalization. Excel replaces only the exact text you typed, so partial matches inside a longer string are replaced too. That is useful for fixing a word inside many sentences, and risky when the search text is short.
Wildcards
In Find and Replace you can use two wildcard characters:
*stands for any number of characters, including none.?stands for exactly one character.
For example, searching for S*n finds "Sun" and "Seven". Searching for ??-001 finds any code with two characters before -001.
To search for a literal * or ?, put a tilde in front of it: ~* finds an asterisk and ~? finds a question mark. To search for a tilde, type ~~. Forgetting this is a common reason a search for "?" matches every cell.
Match entire cell contents
Turn this on when you want to replace whole values and not pieces of them. Consider a column of quantities where some cells contain 0 and others contain 10, 100, or 2.05. Searching for 0 with the option off matches all of those cells, because each one has a zero somewhere. Replacing 0 with n/a would turn 10 into 1n/a. With Match entire cell contents on, only cells that are exactly 0 change.
A related trap: replacing a digit inside a number converts the cell to text. Replacing 100 with 1000 in a number cell works as you expect, because Excel re-reads the result and the cell stays a number. Replacing a comma in 1,500 with nothing, on the other hand, may give you 1500 stored as a number or text depending on how the original was stored. Always check the alignment afterward: numbers are right-aligned by default, and text is left-aligned.
Formulas, values, and the Look in setting
Look in determines what Excel compares against.
- Formulas searches the stored contents. For a formula cell, that means the formula text. For a constant, it means the value you typed.
- Values searches what the cell displays. A cell showing
$1,250.00can be found by searching for1,250. Replace is unavailable when Look in is set to Values in some versions, so you cannot replace displayed text that way.
This is the stored-versus-displayed distinction again. A date entered as 3/5/2026 and formatted as 5-Mar-26 is stored as a serial number. Searching for Mar with Look in set to Formulas finds nothing, because the stored value is a number. Searching with Look in set to Values finds it, because Mar appears in the display. For that reason, Replace cannot change the month name in such a cell. To change the date, you edit the stored value.
Replace can also rewrite formulas. If a formula contains Sheet1!, replacing it with Sheet2! changes every formula that refers to that sheet. This is powerful and easy to get wrong, so test on a copy of the workbook first.
Replacing formats
Click Format next to either box to search for, or apply, a font, fill, number format, or border. You can use Choose Format From Cell to copy the format of an existing cell as the search pattern.
A typical task is turning every yellow-highlighted cell blue. Set the Find format to a yellow fill and the Replace format to a blue fill, leave both text boxes empty, and click Replace All. The text stays the same, and only the format changes.
Excel remembers the last format settings. If a search returns nothing or too little, click the arrow beside Format and choose Clear Find Format and Clear Replace Format.
Replacing with nothing and special characters
Leaving Replace with empty and clicking Replace All deletes the found text. This is the quick way to remove a character such as a stray hyphen or a trailing label from many cells.
To find a line break inside cells, click in the Find what box and press Ctrl+J. The box looks empty, but it holds the line-break character. Put a space in Replace with to turn multi-line cells into single lines. You can do the reverse too, replacing a separator such as ; with a Ctrl+J line break.
A non-breaking space, which comes from copied web content and looks like a normal space, will not match a typed space. Copy one from a cell and paste it into the Find what box, or type Alt+0160 on the numeric keypad.
Undo, scope, and safety
Replace All is a single action, so Ctrl+Z reverses it. Undo works only until you do something that clears the undo history, such as saving in some situations or running a macro. For that reason, take these steps before a big replace:
- Save a copy of the file.
- Select only the range you intend to change.
- Run Find All and read the list.
- Run Replace All, then spot-check several results.
Common errors
- Nothing found, though the text is visible. The text may be a displayed format rather than stored content. Change Look in to Values. Also check for a leftover format filter, a hidden sheet outside the scope, or a non-breaking space.
- Too many cells changed. Match entire cell contents was off, or a wildcard matched more than you meant.
- Numbers turned into text. The replacement produced a string Excel did not re-read as a number. Retype one cell, or use Data, Text to Columns on the column to reconvert.
- Protected sheets. Replace cannot change locked cells on a protected sheet. Excel skips them or shows a message.
- Hidden rows and filtered data. Replace All still changes hidden and filtered-out cells inside the range. If you only want visible cells, select them first with Alt+; (Go To Special, Visible cells only).
Exercise
Column B has the values 5, 50, 500, and a cell containing the text "5 units". You want to change only the cells that are exactly 5 to 6. Which options do you set, and what happens if you do not?
Show answer
Select the range B1:B4 (or the column), open Replace with Find what 5 and Replace with 6, and turn on Match entire cell contents. Only the cell equal to 5 changes. Without that option, Replace All matches every 5 inside a cell, so 50 becomes 60, 500 becomes 600, and "5 units" becomes "6 units".
Exercise
A column of dates shows as 05-Mar-26, but a search for "Mar" with Look in set to Formulas finds nothing. Why, and how can you find the cells?
Show answer
Dates are stored as serial numbers, and Look in Formulas compares the stored value, so the text "Mar" does not exist there. Set Look in to Values, which compares the displayed text, and the search finds the cells. You still cannot use Replace to change the month name, because the stored number has to be edited.