A Macro to delete all but one comma

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I thank anyone in advance who can help me with this. I have a word document that I need to delete a bunch of comma's. It kinda looks like this.

data,,data,,,,,data
data1,data,,data
data2,,,,data,,,,data

I would like a macro that will delete all but one comma from each column per say. So the final result would be:

data,data,data
data1,data,data
data2,data,data

I am not sure how I would even start to do something like that but believe it is possible. Thank you very much in advance and it will save days of work. Thank you

Madchatthew
 
use the edit replace optio

firs
you want to tell it to replace ,, (two commas) with ,,,(three commas) -

then you tell it to replace ,, (two commas) with , (one comma
You keep telling it to replace the ,, with , until it cannot find anymore

Sounds crazy but it works... try it.
 
Sweet thanks...I will give it a try...sounds to simple to work...cool

----- Gidget wrote: -----

use the edit replace option

first
you want to tell it to replace ,, (two commas) with ,,,(three commas) -

then you tell it to replace ,, (two commas) with , (one comma)
You keep telling it to replace the ,, with , until it cannot find anymore.

Sounds crazy but it works... try it.
 
Hey Gidget,

That worked perfect. Literally days saved. Thanks alot. It always amazes me how the answer is right in front of anyones' face...thanks again.

Madchatthew

----- Gidget wrote: -----

use the edit replace option

first
you want to tell it to replace ,, (two commas) with ,,,(three commas) -

then you tell it to replace ,, (two commas) with , (one comma)
You keep telling it to replace the ,, with , until it cannot find anymore.

Sounds crazy but it works... try it.
 
The first step is unnecessary, however. Just start by replacing two with one
and continue till no more replacements are made.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Even quicker for next time is to use a wildcard search.
Replace
(,),{1,}
with
\1
This will remove all the extras in one pass.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
Back
Top