Pinterest Pixel

Add Comma in Excel between Names with SUBSTITUTE Formula

Bryan
While working in an Excel Worksheet, you will come across scenarios where the last name is not separated from the first name by a comma, and doing that manually could be a daunting task.
Good thing that this tutorial teaches you how to add comma in Excel between names using SUBSTITUTE function.

While working in an Excel Worksheet, you will come across scenarios where the last name is not separated from the first name by a comma, and doing that manually could be a daunting task. Good thing that this tutorial teaches you how to add comma in Excel between names using SUBSTITUTE function.

In this tutorial on how to insert comma between words in excel, you will learn:

SUBSTITUTE function is a type of TEXT function and is used to search and replace text strings in Excel. It is a very useful function if you wish to replace an old text with new text.

Let’s jump right in and start exploring the features of this function.

Introduction to SUBSTITUTE function

What does it do?

It replaces specific text in a text string i.e. Substitutes new text for old text in a text string.

Formula breakdown:

=SUBSTITUTE(text, old_text, new_text, [instance_num])

What it means:

SUBSTITUTE function has four arguments – text, old_text, new_text and instamce_num. The first 3 arguments are required and the fourth one is optional.

  • text – The original text in which you want to replace the text. It can be a cell reference, a text string, or a result of another formula.
  • old_text – The text you want to replace
  • new_text – The text you want to replace with
  • instance_num – The occurrence of the old text you want to substitute i.e. 1st occurrence, 2nd occurrence, etc. If it is left blank, all the occurrences are replaced.

Let’s work with an example to know how to use SUBSTITUTE function and how to add a comma in excel between names using this function.

Add comma in excel between names using SUBSTITUTE function

I can recall the countless times when I was given a list of names from the HR department and the last name was not separated from the first name by a comma.

It drove me nuts!!!

I had to manually edit the names one by one, so that it would look like <last name>, <first name>.

Turns out, the SUBSTITUTE formula in Excel would have done this task very easily!

In our example below, we have a list of names.  We want to replace the space with a comma followed by space.  The SUBSTITUTE formula is able to do this for us!

I explain how you can do this and please go this tutorial on how to add comma in Excel between names:

Add Comma in Excel between Names with SUBSTITUTE Formula | MyExcelOnline

download excel workbook Substitute-Add-Comma-Between-Names.xlsx

Follow the steps below to understand how to add comma in Excel between names:

STEP 1: We need to enter the SUBSTITUTE function next to the cell that we want to clean the data from:

=SUBSTITUTE

Add Comma in Excel between Names with SUBSTITUTE Formula

 

STEP 2: The Substitute arguments:

text

Which cell do we want to make changes to?

Reference the cell that contains the text or value:

=SUBSTITUTE(C9,

Add Comma in Excel between Names with SUBSTITUTE Formula

 old_text

Which text/characters do we want to replace?

We want to change the space so type it in:

=SUBSTITUTE(C9, ” “,

Add Comma in Excel between Names with SUBSTITUTE Formula

new_text

Which text/characters do we want to replace it with?

We want to replace it into the comma followed by a space, so type it in:

=SUBSTITUTE(C9, ” “, “, “)

Add Comma in Excel between Names with SUBSTITUTE Formula

STEP 3: Do the same for the rest of the cells by dragging the SUBSTITUTE formula all the way down using the left mouse button.

Note that all of the names are now changed to having your needed commas:

Add Comma in Excel between Names with SUBSTITUTE Formula

This will easily substitute a space between names with a comma followed by space.

Now that you are confident in using the SUBSTITUTE function to add comma in Excel between names, let’s move forward and understand how to use instance_num argument in your formula.

Using instance_num argument in SUBSTITUTE function

Let’s work on an example to understand this function in depth.

 

Add Comma in Excel between Names with SUBSTITUTE Formula

In cell A2, you have the text – “Sales for Quarter 1 Product 1” and you want to replace it with the text “Sales for Quarter 2 Product 2”. You can use the function

=SUBSTITUTE(A2,”1″,”2″)

Add Comma in Excel between Names with SUBSTITUTE Formula

 

 

Say, you want to replace only the first occurrence of 1 with 2 i.e. replace Sales for Quarter 2 Product 1 to Sales for Quarter 2 Product 1. You can use the function

=SUBSTITUTE(A3,”1″,”2″,1)

By adding the instance_num argument, you have restricted Excel to substitute only the first occurrence of 1.

Add Comma in Excel between Names with SUBSTITUTE Formula

Similarly, you can substitute only the second occurrence of 1 with 2 using the formula

=SUBSTITUTE(A4,”1″,”2″,2)

Add Comma in Excel between Names with SUBSTITUTE Formula

 

Substitute vs Replace

Both these functions are used to replace an old text with the new text. The main difference between the two is that:

  • You should use the SUBSTITUTE function when you know which word you want to change
  • You should use REPLACE function when you know the position and length of the characters you want to change.

Let’s learn more about the REPLACE function to understand the difference in detail!

Formula breakdown:

The syntax of the REPLACE function:

=REPLACE (old_text, start_num, num_chars, new_text)

What it means:

  • old_text – The text string in which you want to find the characters to replace.
  • start_num – The starting position where you want the replace function to take place
  • num_chars – The number of characters you want to replace
  • new_text – The replacement text

Example :

Say, you have a text “Excel 2020” in cell A2 and you want to change it to “Excel 2021”. You want to replace 4 characters starting from the 7th character and you want the replacement text to be “2021”. You can do that using the REPLACE function:

=REPLACE (A2, 7, 4,”2021″)

Add Comma in Excel between Names with SUBSTITUTE Formula

Since you also know the text you want to replace using SUBSTITUTE function would also get the work done.

=SUBSTITUTE(A3,”2020″,”2021″)

Add Comma in Excel between Names with SUBSTITUTE Formula

Conclusion

In this tutorial, you have learned how to use the SUBSTITUTE function to add comma in Excel between names. You can learn more about this function by going through this blog on How to clean data using the SUBSTITUTE function.

Make sure to download our FREE PDF on the 333 Excel keyboard Shortcuts here:

Add Comma in Excel between Names with SUBSTITUTE Formula | MyExcelOnline

You can learn more about how to use Excel by viewing our FREE Excel webinar training on Formulas, Pivot Tables, and Macros & VBA!

If you like this Excel tip, please share it



Add Comma in Excel between Names with SUBSTITUTE Formula | MyExcelOnline


Bryan

Bryan Hong is an IT Software Developer for more than 10 years and has the following certifications: Microsoft Certified Professional Developer (MCPD): Web Developer, Microsoft Certified Technology Specialist (MCTS): Windows Applications, Microsoft Certified Systems Engineer (MCSE) and Microsoft Certified Systems Administrator (MCSA).

He is also an Amazon #1 bestselling author of 4 Microsoft Excel books and a teacher of Microsoft Excel & Office at the MyExecelOnline Academy Online Course.

See also  LARGE Formula in Excel

Star 30 Days - Full Access Star

One Dollar Trial

$1 Trial for 30 days!

Access for $1

Cancel Anytime

One Dollar Trial
  • Get FULL ACCESS to all our Excel & Office courses, bonuses, and support for just USD $1 today! Enjoy 30 days of learning and expert help.
  • You can CANCEL ANYTIME — no strings attached! Even if it’s on day 29, you won’t be charged again.
  • You'll get to keep all our downloadable Excel E-Books, Workbooks, Templates, and Cheat Sheets - yours to enjoy FOREVER!
  • Practice Workbooks
  • Certificates of Completion
  • 5 Amazing Bonuses
Satisfaction Guaranteed
Accepted paymend methods
Secure checkout

Get Video Training

Advance your Microsoft Excel & Office Skills with the MyExcelOnline Academy!

Dramatically Reduce Repetition, Stress, and Overtime!
Exponentially Increase Your Chances of a Promotion, Pay Raise or New Job!

Learn in as little as 5 minutes a day or on your schedule.

Learn More!

Share to...