How to replace all characters after the first specific character

This post will guide you how to replace all characters after the first match of a specific character with a new text string in excel. How to replace all substrings after the first occurrence of the comma character with another substring in a text string using excel formula. How to replace all old_text with new_text in a text string.

Replace all characters after the first comma

If you want to replace text before the first match of the comma character in a text string in Cell B1, you need to get all characters after the first comma firstly. And how to extract text after the first comma? We talked the solution in the previous post. You need to use a combination of the MID function and the FIND function to create a formula.

After getting the text after the first comma, you still need to use the SUBSTITUTE function to replace it with new_text “excelhow” in text string in Cell B1. So you need to create a formula based on the SUBSTITUTE function, the MID function and the FIND function as follows:

=SUBSTITUTE(B1,MID(B1,FIND(",",B1)+1,LEN(B1)),"excelhow",1)

Let’s see how this formul works:

=LEN(B1)

The LEN function returns the number of characters in a text string in Cell B1. The returned result goes into the MID function as its num_chars argument.

 

=FIND(“,”,B1)+1

extract text after first comma11

The FIND function returns the position of the first comma character in Cell B1. It returns 6. And then add 1 to get the position of the first character after comma character. So this formula returns 7. The returned value goes into the MID function as its start_num argument.

 

=MID(B1,FIND(“,”,B1)+1,LEN(B1))

extract text after first comma1

x
How to Limit Data Entry in a Cell in Excel

So far, you got the values of the start_num and num_chars arguments from above FIND and LEN formula. And then the MID function extracts a substring based on the starting position and the number of the characters that you want to extract from a text string in Cell B1.

 

=SUBSTITUTE(B1,MID(B1,FIND(“,”,B1)+1,LEN(B1)),”excelhow”,1)

replace after first commas1

This formula will replace the first old_text returned by the LEFT function with new_text “excelhow” in a text string in Cell B1.

 

Replace all characters before a specific character using FIND&Select command

You can also use the Find and Replace command to replace all characters after a specified character, just refer to the following steps:

1# Click “HOME“->”Find&Select”->”Replace…”, then the window of the Find and Replace will appear.

Remove text using Find Select command1

Remove text using Find Select command1

2# click “Replace” Tab, then type ,* into the Find what: text box, and then type “,excelhow” string in the Replace with: text box.

replace after first commas2

3# click “Replace All

replace after first commas3

you will see that all characters after the comma character are replaced with “excelhow” string.


Related Formulas

Related Functions

  • Excel Substitute function
    The Excel SUBSTITUTE function replaces a new text string for an old text string in a text string.The syntax of the SUBSTITUTE function is as below:= SUBSTITUTE  (text, old_text, new_text,[instance_num])….
  • Excel MID function
    The Excel MID function returns a substring from a text string at the position that you specify.The syntax of the MID function is as below:= MID (text, start_num, num_chars)….
  • Excel FIND function
    The Excel FIND function returns the position of the first text string (sub string) within another text string.The syntax of the FIND function is as below:= FIND(find_text, within_text,[start_num])…
  • Excel SEARCH function
    The Excel SEARCH function returns the number of the starting location of a substring in a text string.The syntax of the SEARCH function is as below:= SEARCH  (find_text, within_text,[start_num])…
  • Excel LEN function
    The Excel LEN function returns the length of a text string (the number of characters in a text string).The LEN function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the LEN function is as below:= LEN(text)…
Related Posts

How to Remove All Asterisk Characters from Cells in Excel
How to Remove All Asterisk Characters7

Sometimes when we opening an excel spreadsheet to check data, we may notice that there are some asterisks exist in texts for security or other reasons. If you feel these special characters are invalid you can remove them from cells. ...

How to Convert Date Format from Dot MM.DD.YYYY to Slash MM/DD/YYYY in Excel
Convert Date Format from Dot to Slash 6

We often enter dates in excel tables, and we can enter current date by quickly press ‘Ctrl+;’ simultaneously. If in some cases we enter a date format that is not what we want, we have to switch the date format ...

How to Remove Quotes for Text or Strings in Excel
How to Remove Quotes 8

When we importing data from other source into Excel we may import quotes or quotations from initial file. And we want to remove these quotes from current file, if we remove them one by one it needs a lot of ...

How to Remove Specific Character from Text Cell in Excel
remove specific character from text string6

This post will guide you how to remove a specific character from text cell in Excel. How do I remove certain character from a cell with a formula in Excel 2013/2016. Remove Specific Character Using Find and Replace function Remove ...

How to Count Comma Separated Value in One Cell in Excel
count value separated by comma2

This post will guide you how to count values in a single cell separated by commas with a formula in Excel. How do I count comma separated values in one cell in Excel 2013/2016. Is it possible to have a ...

How to Count the Number of Letters or Numbers separately in a Cell in Excel
count number of letters3

This post will guide you how to count the number of a given character in a cell in Excel. How do I count only numbers within a single cell excluding all letters and other characters with a formula in Excel. ...

How to Remove the First/Last Word from Text string in Cell
remove first last word in cell2

This post will guide you how to remove the first and the last word from a text string in cells in Excel. How do I use a formula to remove first and last word of a text string in Excel. ...

How to Remove Line Breaks (Carriage Returns) in Excel
remove line breaks9

This post will explain that how to remove line breaks in your data set in Excel. How do I remove carriage returns or line breaks with a formula in Excel. How to remove line breaks with VBA Macro in Excel. ...

How to Convert DD-MM-YYYY text string or date to a standard date format in Excel
convert ddmmyyy test to date format1

This post will guide you how to convert dd-mm-yyyy test string or a date to a standard date format mm/dd/yyyy with a formula in Excel. Convert Text DD-MM-YYYY to Date Format Video: Convert DD-MM-YYYYY to Standard Date Format Convert Text ...

How to convert Column Letter to Number in Excel
convert column letter to number8

This post will guide you how to convert column letter to number in Excel. How do I convert letter to number with a formula in Excel. How to convert column letter to number with VBA macro in Excel. How to ...

Sidebar