Macro needed?

  • Thread starter Continental Translations
  • Start date
C

Continental Translations

I am after something which will delete excess spaces in certain cells. In
some of my cells, I have a couple of words. Some of these words however have
2 spaces or 3 spaces in between each word instead of 1. Is there anyway I
can change this so that all words within cells have one space inbetween them
and no spaces before the first word of the cell?

Thanks
 
G

Gord Dibben

For one cell.......=TRIM(A1)

For a whgole whack of cells............

Sub TRIM_EXTRA_SPACES()
Dim cell As Range
For Each cell In Selection
If (Not IsEmpty(cell)) And _
Not IsNumeric(cell.Value) And _
InStr(cell.Formula, "=") = 0 _
Then cell.Value = Application.Trim(cell.Value)
Next
End Sub

Gord Dibben Excel MVP
 
G

Gord Dibben

What the hell is a whogle?



For one cell.......=TRIM(A1)

For a whgole whack of cells............

Sub TRIM_EXTRA_SPACES()
Dim cell As Range
For Each cell In Selection
If (Not IsEmpty(cell)) And _
Not IsNumeric(cell.Value) And _
InStr(cell.Formula, "=") = 0 _
Then cell.Value = Application.Trim(cell.Value)
Next
End Sub

Gord Dibben Excel MVP
 
D

Dave Peterson

I think it was Carnac who asked this question first:

Where does a wg go when it's scared? Down its wghole.

(other questions arose, but they were editted!)
 
Top