ExcelReady
CourseFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before the interview. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Function guides
  • Blog

Product

  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Text
  3. SUBSTITUTE and REPLACE in Excel

SUBSTITUTE and REPLACE in Excel

By ExcelReady Team·Updated October 30, 2026·8 min read

The short answer

Use SUBSTITUTE when you know the text you want to change: =SUBSTITUTE(A2,".","-") swaps every dot for a dash. Use REPLACE when you know the position: =REPLACE(A2,1,3,"XXX") overwrites the first three characters. SUBSTITUTE is case-sensitive and can change just one occurrence; REPLACE ignores what the characters say.

Key takeaways

  • SUBSTITUTE(text, old_text, new_text, [instance_num]) swaps text by what it says.
  • REPLACE(old_text, start_num, num_chars, new_text) swaps text by where it sits.
  • Use an empty string "" as the new text to delete characters.
  • SUBSTITUTE is case-sensitive: "Ltd" will not match "LTD".
  • Nest SUBSTITUTE inside SUBSTITUTE to fix several different characters in one formula.
On this page+
  1. SUBSTITUTE vs REPLACE: which one do you need?
  2. How to use the Excel SUBSTITUTE function
  3. How to change only one occurrence
  4. How to remove characters with SUBSTITUTE
  5. How to fix several characters in one formula
  6. How to use REPLACE to change text by position
  7. How to find the position for REPLACE
  8. Common mistakes with SUBSTITUTE and REPLACE
  9. Practise it

The Excel SUBSTITUTE function swaps one piece of text for another based on what it says, and REPLACE swaps characters based on where they sit. Use SUBSTITUTE to change every dot in a phone number to a dash; use REPLACE to overwrite the first three characters of a code. This guide is for anyone cleaning imported data or preparing for an Excel test, and it shows both functions on small, realistic examples.

SUBSTITUTE vs REPLACE: which one do you need?#

Pick SUBSTITUTE when you can name the text to change, and REPLACE when you can only say where it is.

You know…UseExampleResult
The exact text to swapSUBSTITUTE=SUBSTITUTE("555.201.7788",".","-")555-201-7788
The position and lengthREPLACE=REPLACE("INV-2024-0081",5,4,"2025")INV-2025-0081

Both functions return text and leave the original cell unchanged, so you build the clean version in a new column. Both work in every version of Excel, including Excel for Mac and Excel for the web. For a deeper side-by-side, see SUBSTITUTE vs REPLACE.

How to use the Excel SUBSTITUTE function#

SUBSTITUTE takes the text, the part to remove, the part to put in, and an optional occurrence number.

Excel formula
=SUBSTITUTE(text, old_text, new_text, [instance_num])
ArgumentWhat it means
textThe cell or text to change
old_textThe text to find, in double quotes
new_textWhat to put in its place. "" deletes it
instance_numOptional. Which occurrence to change. Leave it out to change all of them

Here is a list of phone numbers exported from a CRM:

AB
1Phone (raw)Phone (clean)
2555.201.7788555-201-7788
3555.330.1942555-330-1942

In B2, type:

Excel formula
=SUBSTITUTE(A2,".","-")

Excel finds every dot in A2 and puts a dash in its place, giving 555-201-7788. Fill down with Ctrl+D (Windows) or ⌘D (Mac) to clean the rest of the column.

How to change only one occurrence#

Add the fourth argument, instance_num, to change only the first, second or third match. Take the code a-b-c-d:

Excel formula
=SUBSTITUTE("a-b-c-d","-","/",2)

The result is a-b/c-d. Only the second dash changed. This is handy when a code uses the same separator for two jobs, such as a date inside a product reference.

How to remove characters with SUBSTITUTE#

Use an empty string, "", as the new text to delete every copy of a character. To strip dashes from an ID:

Excel formula
=SUBSTITUTE(A2,"-","")

TX-ELC-40512 becomes TXELC40512. The same trick removes thousand separators from numbers that arrived as text: =VALUE(SUBSTITUTE(A2,",","")) turns the text "12,500" into the number 12500. VALUE matters, because SUBSTITUTE always returns text, and SUM skips text.

Removing a character is also the basis for counting it. The length of the text minus the length without the character tells you how many there were, which our guide to counting characters and words in a cell explains step by step.

How to fix several characters in one formula#

SUBSTITUTE handles one old_text at a time, so you nest one inside another to fix two or more different characters. Some phone numbers use dots and others use spaces:

Excel formula
=SUBSTITUTE(SUBSTITUTE(A2,".","-")," ","-")

Excel works from the inside out. The inner SUBSTITUTE changes dots to dashes, then the outer one changes spaces to dashes. You can nest as many as you need, but beyond three or four the formula gets hard to read. At that point, Find and Replace or Power Query is often quicker for a one-off clean.

Stray spaces are a different problem. If a cell has extra spaces at the start, at the end or doubled in the middle, wrap it in TRIM first. The TRIM function guide covers what it removes and what it misses, and our article on cleaning messy data with TRIM, CLEAN and PROPER shows the full clean-up routine.

How to use REPLACE to change text by position#

REPLACE overwrites a number of characters starting at a position you choose, whatever those characters are.

Excel formula
=REPLACE(old_text, start_num, num_chars, new_text)
ArgumentWhat it means
old_textThe cell or text to change
start_numThe position of the first character to replace, counting from 1
num_charsHow many characters to remove
new_textThe text to put in their place

Invoice numbers like INV-2024-0081 need the year updated. The year starts at character 5 and is 4 characters long:

Excel formula
=REPLACE(A2,5,4,"2025")

The result is INV-2025-0081. SUBSTITUTE could also do this, but only if every cell held the same old year. REPLACE doesn't care what the four characters say.

Insert text without removing anything#

Set num_chars to 0 to insert text. =REPLACE("5552017788",4,0,"-") gives 555-2017788: nothing is removed, and the dash is added before character 4.

Mask part of an ID#

REPLACE combines well with REPT, which repeats a character. To hide all but the last four digits of an account reference:

Excel formula
=REPLACE(A2,1,LEN(A2)-4,REPT("*",LEN(A2)-4))

For 5551234567 the result is ******4567. LEN works out how many characters to hide, so the formula fits any length. Our guide to REPT and in-cell bars shows more uses for repeated characters.

How to find the position for REPLACE#

When the position changes from row to row, let FIND or SEARCH work it out. To replace everything before the @ in an email with "user":

Excel formula
=REPLACE(A2,1,FIND("@",A2)-1,"user")

FIND returns the position of the @, and subtracting 1 gives the number of characters before it. The guide to finding the position of text with FIND and SEARCH covers how both work, and LEFT, RIGHT and MID shows how to pull text out instead of swapping it.

Common mistakes with SUBSTITUTE and REPLACE#

These are the errors that come up most often:

  • Expecting SUBSTITUTE to ignore capitals. It is case-sensitive. =SUBSTITUTE(A2,"ltd","Limited") leaves "Ltd" alone. Use =SUBSTITUTE(LOWER(A2),"ltd","limited") if the capitals vary and lowercase output is fine.
  • Swapping the argument order. SUBSTITUTE wants the old text before the new text. =SUBSTITUTE(A2,"-",".") does the opposite of what you meant.
  • Forgetting the quotes. Text arguments go in double quotes: ".", not ..
  • Adding numbers that are now text. Wrap the result in VALUE before you sum it.
  • Giving REPLACE a position that moves. A fixed start_num breaks when codes have different lengths. Use FIND to calculate it.
  • Using SUBSTITUTE to split text. If you want the pieces in separate cells, TEXTSPLIT splits text into columns in one formula.

Practise it#

The fastest way to remember the argument order is to type it a few times on real data. Try the live exercise on this page, then work through the cleaning messy text lesson, where you fix phone separators with nested SUBSTITUTE and tidy names with TRIM and PROPER in a live spreadsheet.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

The phone numbers in column A use dots. In B2, use SUBSTITUTE to replace every dot in A2 with a dash.

fx
ABCD
1
Phone (raw)
Phone (clean)
2
555.201.7788
3
555.330.1942
4
555.874.0016
5
555.612.4470
6
7
8

Tip: Three parts: the cell, the dot in double quotes, then the dash in double quotes.

Practise this in a lesson

LessonCleaning messy textFix stray spaces, random capitals and inconsistent separators in imported data with TRIM, PROPER, UPPER, LOWER and SUBSTITUTE.Function guideTRIMClean imported data with Excel's TRIM: strip leading, trailing and double spaces so lookups and counts work. Examples and live practice.

Frequently asked questions

What is the difference between SUBSTITUTE and REPLACE in Excel?

+

SUBSTITUTE finds text by its content, such as every dash in a phone number. REPLACE changes characters at a position you give it, such as the first three characters, whatever they are.

Is SUBSTITUTE case-sensitive?

+

Yes. =SUBSTITUTE(A2,"ltd","Limited") will not change "Ltd" or "LTD". Wrap the text in LOWER or UPPER first if the capitals vary, or use Find and Replace, which ignores case by default.

How do I remove a character from a cell with a formula?

+

Use SUBSTITUTE with an empty string as the new text. =SUBSTITUTE(A2,"-","") removes every dash from A2.

Can SUBSTITUTE replace several different characters at once?

+

Not in one call. Nest one SUBSTITUTE inside another, so each one handles one character, for example =SUBSTITUTE(SUBSTITUTE(A2,".","-")," ","-").

Why does SUBSTITUTE turn my number into text?

+

SUBSTITUTE and REPLACE always return text. If you need a number back, wrap the formula in VALUE, for example =VALUE(SUBSTITUTE(A2,",","")).

Sources

  • SUBSTITUTE function - Microsoft Support
  • REPLACE, REPLACEB functions - Microsoft Support

Written and checked by the ExcelReady Team. First published October 30, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. SUBSTITUTE vs REPLACE: which one do you need?
  2. How to use the Excel SUBSTITUTE function
  3. How to change only one occurrence
  4. How to remove characters with SUBSTITUTE
  5. How to fix several characters in one formula
  6. How to use REPLACE to change text by position
  7. How to find the position for REPLACE
  8. Common mistakes with SUBSTITUTE and REPLACE
  9. Practise it

Keep reading

Text· 7 min read

TEXTSPLIT in Excel: Split Text Into Columns

TEXTSPLIT splits one cell into several cells at a delimiter you choose. =TEXTSPLIT(A2,",") puts each comma-separated item in its own column, spilling to the right. Add a row delimiter to split into rows as well, and TRUE as the fourth argument to skip empty items. TEXTSPLIT needs Microsoft 365, Excel 2024 or Excel for the web.

Text· 7 min read

Count Characters and Words in a Cell in Excel

To count characters in a cell, use =LEN(A2). It counts every letter, digit, space and symbol. To count one character, subtract the length without it: =LEN(A2)-LEN(SUBSTITUTE(A2,",","")). To count words, count the spaces in the trimmed text and add 1: =LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))+1.

Text· 7 min read

Clean Messy Data in Excel With TRIM, CLEAN and PROPER

Use TRIM to remove extra spaces, CLEAN to remove hidden non-printing characters, and PROPER to put a capital at the start of each word. Nest them to fix several problems at once: =PROPER(TRIM(A2)) turns " maria gonzalez" into "Maria Gonzalez". Build the clean version in a new column, check it, then paste it as values.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback. The first lessons are free, with no download.

Start learning for free