View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] aztecbrainsurgeon@yahoo.com is offline
external usenet poster
 
Posts: 17
Default Trim function as a procedure - a simple example

No question here, just a very simple example procedure for the archive

Sub RemoveAllBlankSpacesButOne()

'Removes all blank spaces = 2 and replaces
'them with just one blank space

Dim cell As Range
On Error Resume Next
For Each cell In Selection
cell.Value = WorksheetFunction.Trim(cell.Value)
Next cell

End Sub

Search critera:
Remove all spaces from a text string except for single spaces between
words and numbers
Remove continous blank spaces greater than two
Trim function as a procedure
Replace continous blank spaces with just one blank space
Trim down blank spaces to one space