All You Need to Know About

REPLACE Formula in Excel

The Excel REPLACE Function is one of the most used Excel Formulas. Learn about the different ways you can apply the REPLACE Function in Excel!

Here are the top things on what you can do with the REPLACE Formula in Excel:

Cleaning Data with Excel’s REPLACE Formula

What does it do?

Replaces part of a text string, based on the number of characters you specify, with a different text string

Formula breakdown:

=REPLACE(old_text, start_num, num_chars, new_text)

What it means:

=REPLACE(this cell, starting from this number, all the way to this number, with this new text)


There are times when we are given a bunch of data that is not clean, is incorrect or just needs to be updated and we need to make some manual adjustments to it.

For example, we have a set of phone numbers that have incorrect area codes in it:

replace-00

We want to change the area code of 817, into the area code 123.

The REPLACE formula in Excel can help you change the text very very easily…goodbye to manual adjustments!

I explain how you can do this below:

DOWNLOAD EXCEL WORKBOOK

STEP 1: We need to enter the Replace function next to the cell that we want to clean the data from:

=REPLACE

STEP 2: The Replace arguments:

old_text

Which text do we want to change?

Reference the cell that contains the text string:

=REPLACE(C10,

replace-01

start_num

Which character do we want to start the replacement from?

We want to replace the area code 817, which starts from the 4th character in the phone number sequence:

1st character is the +

2nd character is the 1

3rd character is the

4th character is the 8

=REPLACE(C10, 4,

 replace-02

num_chars

How many characters do we want to replace?

We want to replace the area code 817, which is 3 characters long:

=REPLACE(C10, 4, 3,

replace-03

new_text

What text will serve as the replacement?

We want to replace the area code 817 with the area code 123:

=REPLACE(C10, 4, 3, “123”)

replace-04

STEP 3: Do the same for the rest of the cells by dragging the REPLACE formula all the way down using the left mouse button.

Note that all of the phone numbers are now clean:

replace-05

Change Phone Area Codes with Excel’s REPLACE Formula

What does it do?

Replaces part of a text string, based on the number of characters you specify, with a different text string

Formula breakdown:

=REPLACE(old_text, start_num, num_chars, new_text)

What it means:

=REPLACE(this cell, starting from this number, all the way to this number, with this new text)


There are times when we are given a bunch of data that is not clean, and we needed to make manual adjustments to it.

For example, we have a set of phone numbers that have incorrect area codes in them.

We want to replace each phone number’s old area code with a new area code, specified in the NEW column:

replace-phone-area-00

We want to change the area code of 370, into the area code of 111.

For the second phone number, we want to change the area code of 961 to 222…and so on.

The REPLACE formula in Excel can help you clean & replace the text very very easily…goodbye to slow manual adjustments!

I explain how you can do this below:

DOWNLOAD EXCEL WORKBOOK

STEP 1: We need to enter the Replace function next to the cell that we want to clean the data from:

=REPLACE

STEP 2: The Replace arguments:

old_text

Which text do we want to change?

Reference the cell that contains the text string:

=REPLACE(A11,

replace-phone-area-01

start_num

Which character do we want to start the replacement from?

We want to replace the area code 370, which is the 2nd character in the phone number.  The open parenthesis ( is the 1st character:

=REPLACE(A11, 2,

 replace-phone-area-02

num_chars

How many characters do we need to replace?

We want to replace the area code 370, which is 3 characters long:

=REPLACE(A11, 2, 3,

replace-phone-area-03

new_text

What text will serve as the replacement?

We want to replace the area code 370 with the area code of 111. The replacement values are in the next column (column B):

=REPLACE(A11, 2, 3, B11)

replace-phone-area-04

STEP 3: Do the same for the rest of the cells by dragging the REPLACE formula all the way down using the left mouse button.

Note that all of the phone numbers are now clean:

replace-phone-area-05

Extract Last Name with Excel’s REPLACE Formula

What does it do?

Replaces part of a text string, based on the number of characters you specify, with a different text string

Formula breakdown:

=REPLACE(old_text, start_num, num_chars, new_text)

What it means:

=REPLACE(this cell, starting from this number, all the way to this number, with this new text)


I had a scenario where I wanted to extract the last names from a list of names using a formula.

Did you know that we can creatively use the Replace formula to replace the first name with an empty string, leaving us with the SURNAME?

Here is what we want to happen:

replace-extract-last-name-06

I explain how you can do this below:

DOWNLOAD EXCEL WORKBOOK

STEP 1: To start off, let us try the Search function and see what it will give us. We want to search on which character the space resides on.   Type in:

=SEARCH(” “, C11)

replace-extract-last-name-00

You will see that it returned 6.

This means our space is on the 6th character of the name Talon Ferguson.

We will use this in our Replace function later in STEP 3.

replace-extract-last-name-01

STEP 2: Clear the Search function. We need to enter the Replace function next to the cell that we want to clean the data from:

=REPLACE

STEP 3: The Replace arguments:

old_text

Which text do we want to change?

Reference the cell that contains the text string:

=REPLACE(C11,

replace-extract-last-name-02

start_num

Which character do we want to start the replacement from?

We want to replace the first name, which resides on the first character:

=REPLACE(C11, 1,

 replace-extract-last-name-03

num_chars

How many characters do we need to replace?

We don’t have the exact number of characters, so this is where the SEARCH function comes in handy from STEP 1 above.

Search for the space character ” “ which tells us the end of the First Name:

=REPLACE(C11, 1, SEARCH(” “, C11),

replace-extract-last-name-04

new_text

What text will serve as the replacement?

Now that we have accounted for all the characters from the First Name, we need to clear these.

We can do this by replacing it with an empty string.

This will “erase” the First Name, and leave us with the Last Name.

=REPLACE(C11, 1, SEARCH(” “, C11), “”)

replace-extract-last-name-05

STEP 4: Do the same for the rest of the cells by dragging the REPLACE formula all the way down using the left mouse button.

Now we have all of the last names:

replace-extract-last-name-06

Latest Tutorials

Want to get better at Excel?

Join Our Excel Community

Get our Free Weekly Excel lesson plans that cover the must know Excel features and tips to make you better at Excel!
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]
[l]