Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Formula - insert space after each instance of a specific character

Posted on 2013-12-17
Medium Priority
268 Views
I need to create a formula that looks at a given cell, finds all instances of a specific character, and does a substitute or replaement.

I need to have a formula that inserts a space after each comma....one that either replaces the "," with ", " or that just finds the comma and inserts a space.

For example:
cell might show the following - First National Bank,Anytown,US,12345
Needs to show as First National Bank, Anytown, US, 12345
0
Question by:IO_Dork
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 43

Accepted Solution

Saqib Husain, Syed earned 2000 total points
ID: 39724796
=substitute(a1,",",", ")
0

LVL 43

Expert Comment

ID: 39724800
If you end up with commas followed by two spaces then try this

=substitute(substitute(a1,",",", "),",  ",", ")
0

Author Comment

ID: 39724842
the amount of commas could and may vary...is there a formula to address this variability?
0

LVL 50

Expert Comment

ID: 39724852
SUBSTITUTE will replace all the commas, so the number doesn't matter

You can address the double space issue with TRIM, i.e. amending Saqib's suggested formula like this

=TRIM(SUBSTITUTE(A1,",",", "))

regards, barry
0

LVL 15

Expert Comment

ID: 39724906
CTRL+R
0

Author Closing Comment

ID: 39724934
Thanks, worked perfectly with no extra spaces.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URLâ€™s and adds a header titled â€śURL Listâ€ť. It then searches through all URLâ€™s in column â€śAâ€ť, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URLâ€™s are then highligâ€¦
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to usâ€¦
###### Suggested Courses
Course of the Month9 days, 12 hours left to enroll