Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or
0
0
0
s2smodern

How to use Replace function to replace and add string in Excel?

In Excel, we may use the Find and Replace function to find a string then replace with another one. But in many cases, the Find and Replace function cannot satisfy your request. Here I introduce how to use the Replace function to solve some problems in Excel.

Replace function


Replace function


=REPLACE(text, start_num, num_chars, new_text)

Case 1 Replace character string in the specific location with other in a string

=REPLACE(text, startnum, numchars, newtext)

If you want to replace a character string in a specific location with another string as below screenshot shown,
doc replace function 1

you can do as this:

Select a cell which you will place the result and type=REPLACE(A1,3,3,"KTE"), and drag fill handle over the cells you use. See screenshot shown.
doc replace function 2

Case 2 Replace multiple character strings in multiple locations with others in a string

=REPLACE(REPLACE(text,stratnum,characternumber,"newtext"),startnum,characternumber,"newtext)

If you want to replace multiple character strings in locations with other strings as below screenshot shown,
doc replace function 3

Do as this:

Select a cell which you will place the result and type =REPLACE(REPLACE(A7,7,1,"1"),15,1,"3"), drag fill handle over the cells you use. See screenshot shown.
doc replace function 4

Case 3 Replace year/mont/day in Date format

=REPLACE(TEXT(text, "dd-mmm-yy"), 4, 3, "newtext")

If you have a range of cells in the special date format 1-Oct-18, what you need is to replace the month to Nov as below screenshot shown,
doc replace function 5

Use this formula

Select a cell which you will place the result and type =REPLACE(TEXT(A14, "dd-mmm-yy"), 4, 3, "Nov"), drag fill handle over the cells you use. See screenshot shown.
doc replace function 6

Case 4 Convert number to date

=DATEVALUE(REPLACE(REPLACE(text,3,0,"/"),6,0,"/"))

If you want to convert text number to standard dates as below screenshot shown, do as this:
doc replace function 7

Select a cell which you will place the result and type =DATEVALUE(REPLACE(REPLACE(A21,3,0,"/"),6,0,"/")), drag fill handle over the cells you use, the format the cells as Short Date format. See screenshot shown.
doc replace function 8
doc replace function 9

Case 5 Replace character string with other in the string

=REPLACE(textreference, FIND("oldtext",textreference), numbercharacter, "newtext")

If you want to replace a string with another in the string as below screenshot shown,
doc replace function 10

Just use the Replace function and Find function

Select a cell which you place the result and type =REPLACE(A28, FIND("@abc",A28), 4, "@bca"), drag fill handle over the cells you use. See screenshot shown.
doc replace function 11

Tip: This formula only work for the first occurrence of string.
doc replace function 12

Case 6 Add new character into specific location of the string

=REPLACE(REPLACE(text,startnumber,0,"newtext"),startnumber,0,"newtext")

If you want to add new character into specific locations of a string as below screenshot shown.
doc replace function 13

Just do as this

Select a cell which you will place the result and type =REPLACE(REPLACE(A34,4,0,"-"),8,0,"-"), drag fill handle over the cells you use. See screenshot shown.
doc replace function 14

Easily Combine columns or rows without losing data in Excel

Supposing you are working with a worksheet which contains multiple duplicate records, and now you need to combine / merge the rows based on the same value and do some calculations, such as sum, average, count of the duplicate rows. With this Advanced Combine Rows of Kutools for Excel, you can quickly combine same values / same data or duplicate rows into appropriate cells.  Click for 60 days free trial!
doc advanced combine rows
 
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days.

Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 300 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

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.