Remove space in character one

  • Thread starter Thread starter Annette
  • Start date Start date
A

Annette

I need to remove a space left in front of text ... in column A and column D
to clean up the ss so that a sort can be done. How would I do that through
code?
 
With code you can do this

Sub test()
For Each cell In Columns("A").SpecialCells(xlCellTypeConstants)
cell.Value = Trim(cell.Value)
Next
End Sub
 
Another alternative:

Public Sub LeftTrimAandD()
Dim rCell As Range
On Error Resume Next
For Each rCell In Range("A:A,D:D").SpecialCells( _
xlCellTypeConstants, xlTextValues)
With rCell
.Value = LTrim(.Value)
End With
Next rCell
On Error GoTo 0
End Sub
 
Back
Top