Replace Last Comma in String with “and” word

This post will guide you how to replace last comma character in a string in cells with “and” word in excel. How do I replace the last comma character from a string with another word “and” using an excel formula. How to replace last instance of comma with ‘and’ in a string in excel.

Replace Last Comma in String with “and”


If you have a list of data (B1:B4) that contain the text string and each word is separated by comma character. And you want to replace the last comma character with a new word “and”. How to achieve it.

You need to create a new complex formula based on the SUBSTITUTE function, and the LEN function to achieve the result. Just do the following steps:

#1 select one blank cell and type the following formula into the formula box.

=SUBSTITUTE(B1,","," and",LEN(B1)-LEN(SUBSTITUTE(B1,",","")))

replace last comma1

#2 then press Enter key in your keyboard and drag the AutoFill Handler over other cell to apply this formula.

You will that all last commas in each selected cells have been replaced with “and” word.

replace last comma2

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 LEN function
    The Excel LEN function returns the length of a text string (the number of characters in a text string).The syntax of the LEN function is as below:= LEN(text)…
Related Posts

Find and Replace Multiple Values

This post will guide you how to find and replace multiple values at once with VBA macro or using formula  in Excel. How do I make multiple find and replace in Excel. Suppose that you have a few cells containing ...

Extract Last Two Words From Multiple Cells

Just assume that you have a few cells containing values/words and you want to extract the last two words from each cell into another separate cell; then you might think that it's not a big deal; because you would prefer ...

Extract Multiple Lines From A Cell

Suppose that you have listed some text in a single cell which is separated by the line break(you can do it by pressing ALT + ENTER after entering the text), and now you want to extract multiple lines of text ...

How to Remove All Asterisk Characters from Cells in Excel

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

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 ...

Comments

So empty here ... leave a comment!

Leave a Reply

Sidebar