Excel Find and Replace Part of a String in a Cell or Range

How-to basics · Updated November 3, 2026

Excel Find and Replace Part of a String in a Cell or Range

To replace part of a string in Excel, press Ctrl+H on Windows, enter the text to find and its replacement, then choose Replace or Replace All. For a repeatable, non-destructive result, use the SUBSTITUTE function, such as =SUBSTITUTE(A2,"old","new"), which changes matching text in the value in A2 without editing the original cell.

What “part of a string” means in Excel

A string is text stored in a cell. Replacing part of one means changing a matching word, phrase, character, or pattern while leaving the surrounding text intact. For example, changing “North depot” to “West depot” in “North depot – morning shift” keeps the rest of the cell’s contents.

Excel offers two main approaches. Find and Replace edits selected cells directly, which is convenient for a one-time cleanup. A formula creates an updated result in another cell, so the source remains available and the change can recalculate if the original text changes. Choose based on whether you want to overwrite data or generate a separate result.

Use Find and Replace for a direct edit

In Excel for Microsoft 365 on Windows, select the cells you want to change, then choose Home > Find & Select > Replace, or press Ctrl+H. Type the exact text to locate in Find what and the replacement in Replace with. Select Replace to review matches one at a time, or Replace All to update every match within the search scope.

  1. Save or make a copy of important data before a large replacement.
  2. Select the relevant cells, column, or range. With no range selected, Excel can search the worksheet.
  3. Open Replace and enter the text to find and the new text.
  4. Check the search options, especially where Excel searches and whether it matches case or entire cell contents.
  5. Use Find Next or Replace to inspect individual hits, or choose Replace All when the scope and match are clear.
  6. Read the completion message, then inspect several changed cells and any nearby rows that should not have changed.

On Mac, use Home > Find & Select > Replace; keyboard shortcuts can vary with the keyboard layout and Excel version, so the ribbon command is a reliable route. In Excel for the web, use the Home tab’s Find & Select controls and choose Replace if available in your current interface. The web app may present fewer advanced search options than desktop Excel. If the command is not visible, use the ribbon search box to look for Replace.

Choose the search scope and matching options

Before replacing, open the options in the Find and Replace dialog. Within determines whether Excel searches the current sheet or the workbook. Searching the workbook is useful for a project-wide terminology change, but it can also alter sheets you did not intend to touch. A selected range limits the operation, making it safer for targeted cleanup.

Match case controls whether uppercase and lowercase letters must agree. By default, a search for “east” can match “East”; turn on Match case when capitalization is meaningful. Match entire cell contents restricts the match to a cell that contains only the search term. Leave it off to find text embedded in longer entries, such as “east entrance.”

Search by Rows or Columns changes the order Excel uses to move through matches; it does not change which text qualifies. Look in lets you search formulas, values, or other supported cell content. Searching formulas can find text inside formula expressions, not just what a formula displays. Be cautious: replacing text in formulas may alter their logic or references. For most cleanup of visible text, choose the appropriate value-oriented search setting and inspect the results.

Use SUBSTITUTE to create a changed version

SUBSTITUTE is often the best choice when you want to preserve the original and show the edited text in a new column. With the original string in A2, enter a formula in B2 and fill it down. The function searches for the specified old text and returns a version with the matching text replaced.

With the text “East depot / East region” in A2, this formula in B2 returns “West depot / West region”: =SUBSTITUTE(A2,"East","West"). It replaces every occurrence of the old text by default. If the original cell is blank or does not contain the search text, the formula returns the original content unchanged.

To replace only one particular occurrence, use the optional fourth argument. With “AB-12-34” in A2, this formula returns “AB-12/34” because it changes only the second hyphen: =SUBSTITUTE(A2,"-","/",2). The instance number counts occurrences from left to right. If that numbered occurrence does not exist, the text is returned without that replacement.

When the output is correct and you need to overwrite the source, copy the formula results and use Paste Special > Values. This replaces formulas with their current results. Keep a backup or retain the source column until you have checked the values; once pasted over the original, the formula no longer provides a live link to it.

SUBSTITUTE versus REPLACE

These functions sound similar but solve different problems. SUBSTITUTE finds a particular sequence of characters, wherever it appears. REPLACE changes a specified number of characters starting at a specified position. Use SUBSTITUTE when you know the text to locate; use REPLACE when you know the position and length of the portion to change.

For example, if A2 contains the product code “AB1234,” the formula =REPLACE(A2,3,0,"-") returns “AB-1234.” It inserts a hyphen at position three because the number of characters to replace is zero. By contrast, a SUBSTITUTE formula would be more appropriate if the target were a known character or text fragment rather than a fixed location.

REPLACE can be fragile when the source strings have different lengths or formats. If one code has a prefix of two characters and another has a prefix of three, a fixed character position might not identify the same logical boundary in both. In those cases, use SUBSTITUTE for a distinctive delimiter or use a more tailored text formula. For current Microsoft 365 and Excel 2021 or later, functions such as TEXTBEFORE and TEXTAFTER can help split text around a delimiter, but they are not necessary for a simple replacement.

Case sensitivity, exact text, and wildcards

Find and Replace is generally case-insensitive unless Match case is selected. The SUBSTITUTE function, in contrast, is case-sensitive: a formula looking for “east” does not replace “East.” If capitalization varies, normalize the text first or use a formula designed for the required matching rule. Avoid changing case across an entire dataset unless that is genuinely desired.

Excel’s Find and Replace also supports wildcard characters in the search field. An asterisk represents any number of characters, and a question mark represents one character. For example, searching for “pre*ship” can match text beginning with “pre” and ending with “ship,” with any intervening characters. The tilde escapes a wildcard when you want to find it literally: use ~* to search for an asterisk and ~? to search for a question mark.

Wildcards can make a search much broader than it looks. A Replace All using a pattern may alter many different strings, and the replacement field does not provide regular-expression capture groups for preserving arbitrary matched portions. Test a wildcard search with Find Next first, and use a narrow selection or a copy of the data. Wildcards apply to Find and Replace; they are not special pattern syntax in SUBSTITUTE.

Common problems and safer checks

  • Too many cells change: Check whether the search is limited to the selected range or spans the workbook. Use Replace one match at a time if the target text appears in different contexts.
  • A longer word changes unexpectedly: A search for a short fragment can match inside another word. Use a more distinctive phrase, Match entire cell contents where appropriate, or inspect hits before replacing.
  • The formula does not match: Confirm the old text’s spaces, punctuation, and capitalization. SUBSTITUTE is case-sensitive, and a nonbreaking space or trailing space can look like an ordinary space.
  • A number or date does not behave like text: Excel stores many dates and numbers as numeric values with display formats. Find and Replace may act on displayed or underlying content depending on the search setting. For predictable text edits, consider creating a text result deliberately rather than assuming the displayed formatting is the stored string.
  • Formulas change unexpectedly: Review Look in and avoid searching formulas unless you intend to edit formula text. A replacement can modify a quoted label inside a formula or other text in the expression.
  • Nothing changes: Check the selected range, search scope, Match case, entire-cell option, and whether the text is in a value or formula. Also check whether the cell is protected or the worksheet is protected.

For many ordinary replacements, Ctrl+Z can undo a Replace All operation, but do not treat undo as a backup strategy. Several later actions can make recovery less convenient, and saving or closing a workbook changes what may be available to undo. Keep an untouched copy before broad edits, especially when working with imported data, formulas, or shared workbooks.

When to use a formula, a direct replacement, or another tool

Use Find and Replace when the same known substring should be edited directly in a limited set of cells. Use SUBSTITUTE when the change should be visible in a separate output column, repeated as new rows arrive, or reviewed before replacing the source. Use REPLACE for fixed-position edits, but only when character positions are consistent across records.

For a large, recurring cleanup across imported files, Power Query may be more maintainable than repeating manual replacements. In Excel for Microsoft 365 on Windows, start from Data > Get Data to import or connect to data, then use the Power Query Editor’s Replace Values command on the relevant column. The exact import route depends on the source. A saved query can apply the same transformation again when refreshed, while Find and Replace is a direct edit and does not create a reusable data-cleaning process.

For a one-off change, a formula or dialog is usually quicker than building a query. The deciding questions are whether you need to preserve the original, whether the same transformation will recur, and whether the match is precise enough to apply safely. Make a small test on representative rows before applying any method to a large or important dataset.

Frequently Asked Questions

Can Excel replace only part of a cell’s text?
Yes. In Find and Replace, leave Match entire cell contents turned off and search for the substring. Replace changes only the matching portion, leaving the rest of the cell intact.

How do I replace just the first or second occurrence?
For a formula-based result, use SUBSTITUTE’s optional instance number. For example, =SUBSTITUTE(A2,"-","/",2) changes only the second hyphen in the text in A2. The dialog’s Replace command lets you handle matches individually, but Replace All changes all qualifying matches.

Can I replace text in multiple worksheets?
Yes. In the desktop Find and Replace options, set Within to Workbook rather than Sheet. Check the workbook scope carefully, because the same text may appear in notes, labels, or formulas on other sheets.

Why does SUBSTITUTE not find text that looks identical?
SUBSTITUTE is case-sensitive and requires the specified characters to match. Differences in capitalization, spaces, punctuation, or invisible characters can prevent a match. Check the source text closely, including leading and trailing spaces.

Does Find and Replace change the original cell?
Yes. Replace and Replace All edit the matching cell contents directly. A SUBSTITUTE formula returns a changed result in the formula cell instead, leaving the source unchanged unless you later paste the result over it.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.