Replacing commas with ampersand

Declamatory

Active Member
Joined
Nov 6, 2014
Messages
319
Hi Folks,

We have a new admin system. When the data was migrated to our new system the accounts that were held in joint names names came across with commas after each person's name. Where an account was previously held in joint names but now is an account held by a sole individual there is a comma after the person's name. We can have up to five joint holders on an account. We have ended up with accounts that looks like the following.

John Smith

David Anderson, Karen Anderson

Jeffrey Jones, Derek Jones, Andrew Jones, Kevin Jones, Andrea Jones

Karl Brown,

William Downing, Blake Downing,

Using Microsoft CRM we can export the client names into excel, tidy them up and import them back into CRM. We would like each account to have an ampersand between account holders so the data would look as follows:

John Smith

David Anderson & Karen Anderson

Jeffrey Jones & Derek Jones & Andrew Jones & Kevin Jones & Andrea Jones

Karl Brown

Is there a formula or VBA code that would solve this?

Thanks in advance
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello,

Have you tested the Substitute() function ...???
 
Upvote 0
But if I substituted , with & I would end up with some accounts where the last client or a sole account would have an ampersand after there name so it would look like "William Downing & Blake Downing &"
 
Upvote 0
Try
Excel Workbook
AB
1John SmithJohn Smith
2David Anderson, Karen AndersonDavid Anderson & Karen Anderson
3Jeffrey Jones, Derek Jones, Andrew Jones, Kevin Jones, Andrea JonesJeffrey Jones & Derek Jones & Andrew Jones & Kevin Jones & Andrea Jones
4Karl Brown,Karl Brown
5William Downing, Blake Downing,William Downing & Blake Downing
Replace comma
 
Last edited:
Upvote 0
or perhaps

=TRIM(SUBSTITUTE(SUBSTITUTE(A2,", "," & "),",",""))


or

=SUBSTITUTE(SUBSTITUTE(TRIM(A2),", "," & "),",","")
 
Last edited:
Upvote 0
Thanks for your answers. The first two suggestions left me with clients that had an ampersand after their name.

William Downing, Blake Downing, resulted in William Downing & Blake Downing &

The final suggestion worked a treat. Thank you for your assistance. It's much appreciated
 
Upvote 0
The first two suggestions left me with clients that had an ampersand after their name.
Sounds like there must have been some space characters after the final comma that we couldn't see. :)
Anyway, glad you got something that worked.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top