View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DataFreakFromUtah DataFreakFromUtah is offline
external usenet poster
 
Posts: 36
Default Delete leading or trailing blank spaces in cell - an example

No question here, just a couple of procedures for the archive.

Sub DeleteTrailingBlankSpacesOnTheRight()
'Deletes trailing blank spaces on the right of a string
Dim cell As Range
For Each cell In Selection
cell.Value = RTrim(cell.Value)
Next cell
End Sub

Sub DeleteLeadingBlankSpacesOnTheLeft()
'Deletes leading blank spaces on the left of a string
Dim cell As Range
For Each cell In Selection
cell.Value = LTrim(cell.Value)
Next cell
End Sub



Search criteria: delete leading spaces on left
delete spaces on left
delete spaces to the left
delete trailing spaces on right
delete spaces on left
delete spaces to the left
delete blank spaces on left of string
delete blank spaces on right of string
delete blank spaces to left of string
delete blank spaces to right of string