Solved

Formula - insert space after each instance of a specific character

Posted on 2013-12-17
6
224 Views
Last Modified: 2013-12-17
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
Comment
Question by:IO_Dork
6 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
Comment Utility
=substitute(a1,",",", ")
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
If you end up with commas followed by two spaces then try this

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

Author Comment

by:IO_Dork
Comment Utility
the amount of commas could and may vary...is there a formula to address this variability?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 50

Expert Comment

by:barry houdini
Comment Utility
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

by:Ess Kay
Comment Utility
CTRL+R
0
 

Author Closing Comment

by:IO_Dork
Comment Utility
Thanks, worked perfectly with no extra spaces.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now