Excel REPLACE function

The REPLACE function in Excel can help you to find and replace characters based on given location from text string with a new text. Take the below screenshot as example, replace 4 characters (2019) which start at the fifth character from the text string with another text string (2020).


 Syntax:

The syntax for the REPLACE function in Excel is:

=REPLACE (old_text, start_num, num_chars, new_text)


 Arguments:

  • old_text: Required. The text string that you want to replace with some characters.
  • start_num: Required. The position of the first character in the text that you want to replace.
  • num_chars: Required. The number of characters you want to replace.
  • new_text: Required. The new text that will replace the old_text.

Note:
An #VALUE! error value will appear, if the start_num or num_chars is negative or non-numeric.


 Return:

Return a string or text value.


 Examples:

Example 1: Basic uses of the REPLACE function

For example, I have a list of text strings, now, I want to replace the first three characters with a specific text as below screenshot shown.

For solving this job, please apply the below formula:

=REPLACE(A2,1,3,"Extendoffice")

And then, drag the fill handle down to apply this formula to other cells you need, see screenshot:


Example 2: using REPLACE function with dates

If you want to replace the day, month or year from a date to other day, month or year as below screenshot shown, the REPLACE function will not get the correct result when using it directly. Here, you should apply the TEXT function to convert the date format to text string firstly, and then use the REPLACE function.

Please apply the following formula:

=REPLACE(TEXT(A2, "dd-mmm-yy"), 4, 3, "Dec")

Then, drag the fill handle down to the cells that you want to sue this formula, and you will get the result as you need:


Example 3: Using REPLACE function to replace text with blank

With this REPLACE function, you can also replace the characters with blank. For example, to replace the first four characters with blank as following screenshot shown.

Please copy or enter the following formula into a blank cell:

=REPLACE(A2,1,4,"")

And, all the first four characters of the text in each cell has been replaced with a blank. See screenshot:


Example 4: using REPLACE function to extract username from Email address

To extract the username from the Email address, the REPLACE function also can do you a favor.

Enter or copy the following formula into a blank cell:

=REPLACE(A2,FIND("@",A2),LEN(A2)-FIND("@",A2)+1,"")

And then, drag the fill handle down to the cells that you want to apply this formula, and all the usernames from each cell have been extracted at once:


 More Functions:

  • Excel REPT Function
  • The REPT function is used to repeat the characters a specified number of times.
  • Excel SEARCH Function
  • The SEARCH function can help you to find the position of a specific character or substring from the given text string.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.