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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top