Simplifies the delimiters

kayza

Board Regular
Joined
Apr 29, 2015
Messages
61
Office Version
  1. 2007
Platform
  1. Windows
Hi, all

I try to simplify my data which has an uncertain number of delimiters. sample data as follows
A1 : one-two--three---four----five-----
the results I expect are like this
B1 : one-two-three-four-five

thanks in advance
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
1. Note Mike's suggestion has a typo. It should be
=SUBSTITUTE(TRIM(SUBSTITUTE(A1,"-"," "))," ","-")

2. If your data could actually contain spaces (eg "Green apple-red apple----ripe banana") then this extension of Mike's formula could be used
=SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(A1," ","#"),"-"," "))," ","-"),"#"," ")
 
Upvote 0
2. If your data could actually contain spaces (eg "Green apple-red apple----ripe banana") then this extension of Mike's formula could be used
=SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(A1," ","#"),"-"," "))," ","-"),"#"," ")
@kayza,

If your text could possibly have a # sign in it, then change the red highlighted # signs in Peter's formula to a different symbol that would never appear in your text. Alternately, you could use this variation to Peter's formula that should work with any text that you might normally be expected to have...

=SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(A1," ",CHAR(1)),"-"," "))," ","-"),CHAR(1)," ")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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