replace several spaces with single space

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

replace several spaces with single space

Post by Robie »

Hi

How can easily replace 2 or more spaces between words with a single space?

Also, is there a way I can delete a table row if all columns are empty? Can I use a Find/Replace of some sort to do this or do I need to write some VBA that process all tables/rows checking for empty cell and deleting the row? :-(

Thanks.
Robie

User avatar
DaveA
GoldLounger
Posts: 2599
Joined: 24 Jan 2010, 15:26
Location: Olympia, WA

Re: delete all spaces between words

Post by DaveA »

Do you mean 2 or more spaces, other wise the words would run together?

If it 2 or more, just do a Replace of 2 spaces for 1. This may need to be run several times.

I would sort the table, and all of the blank rows would be grouped and the you could select and delete them.
But then you would need to resort to back to the way it was before the first sort.
I am so far behind, I think I am First :evilgrin:
Genealogy....confusing the dead and annoying the living

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: delete all spaces between words

Post by Robie »

DaveA wrote:Do you mean 2 or more spaces, other wise the words would run together?

If it 2 or more, just do a Replace of 2 spaces for 1. This may need to be run several times.

I would sort the table, and all of the blank rows would be grouped and the you could select and delete them.
But then you would need to resort to back to the way it was before the first sort.
Thanks for the response Dave.
Basically, I would like to replace 2 or more spaces between words with a single space. Sorry, my original post was not clear.

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: replace several spaces with single space

Post by Robie »

Update to my OP:

I have managed to find an old macro which removes empty rows from the table. So, i will try to use that one.

Thanks.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: replace several spaces with single space

Post by Rudi »

Robie wrote:How can easily replace 2 or more spaces between words with a single space?
Try this:

1. Press Ctrl+H to open the Find and Replace dialog box.
2. Click the More button to display the search options.
3. Select the Use wildcards check box (this method won’t work unless this option is turned on).
4. In the Find what field, press the spacebar once followed by {2,}. (Two spaces minimum followed by a comma indicating any amount maximum)
5. In the Replace with field, press the spacebar once.
6. Click Replace All.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78471
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: replace several spaces with single space

Post by HansV »

Even easier (but it may not always do what you want):
- Press Ctrl+H to activate the Replace dialog.
- Enter ^w in the 'Find what' box. This stands for 'white space' - any combination of spaces and tab characters.
- Enter a single space in the 'Replace with' box.
- Click 'Replace All'.
Best wishes,
Hans

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: replace several spaces with single space

Post by Robie »

Rudi wrote:
Robie wrote:How can easily replace 2 or more spaces between words with a single space?
Try this:

1. Press Ctrl+H to open the Find and Replace dialog box.
2. Click the More button to display the search options.
3. Select the Use wildcards check box (this method won’t work unless this option is turned on).
4. In the Find what field, press the spacebar once followed by {2,}. (Two spaces minimum followed by a comma indicating any amount maximum)
5. In the Replace with field, press the spacebar once.
6. Click Replace All.
Thanks Rudi. That works wondefully well. :cheers:

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: replace several spaces with single space

Post by Robie »

HansV wrote:Even easier (but it may not always do what you want):
- Press Ctrl+H to activate the Replace dialog.
- Enter ^w in the 'Find what' box. This stands for 'white space' - any combination of spaces and tab characters.
- Enter a single space in the 'Replace with' box.
- Click 'Replace All'.
You are right Hans. This is even easier. Like it very much. :clapping: