Remove unnecessary commas and space from cells

Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,

I currently have a very large data sheet that looks like this:

1660291617565.png


In this example, I've just put in a format of: Date,Name,Gender

Please note that some of the cells however might only have Date,Gender or Name,Gender or Date,Gender etc.

My ideal format would be: Date,Name,Gender

However, as you can see, many of them have it pasted as "Date,,,, Name ,,,Gender" with a lot of unnecessary commas and spaces

Does anybody know how to remove these duplicate values? Essentially I want all cells to have zero spaces and just one comma inbetween the values (so Date,Name,Gender as the format)

I would truly appreciate some assistance here! :)

Thank you all!

Kind regards,
Jyggalag
 
Could also use Text to columns, then join back up again with a simple & (with TRIM if needed) formula.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you don't have those latest TEXT functions yet, try

22 08 12.xlsm
AB
112/08/2022,George,,,Male12/08/2022,George,Male
211/08/2022,,,Elizabeth,,,Female11/08/2022,Elizabeth,Female
310/08/2022 ,,Thomas ,,Male10/08/2022,Thomas,Male
409/08/2022,,,,,Female09/08/2022,Female
5John ,,,,MaleJohn,Male
Commas
Cell Formulas
RangeFormula
B1:B5B1=SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(A1," ",""),","," "))," ",",")


This worked! Amazing!

1660301507677.png


Thank you so much Peter!! :)

Also everyone else thank you so much too, I really appreciate all the nice input I got here! :)
 
Upvote 0

Forum statistics

Threads
1,225,739
Messages
6,186,746
Members
453,370
Latest member
juliewar

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