Skip to main content

Excel REPLACE function

Author: Xiaoyang Last Modified: 2022-09-01

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 in which you want to replace 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

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ...
Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup...
Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List...
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Description


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, Edge and Firefox.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations