Tidying up imported text column

  • Thread starter Thread starter Phil Latio
  • Start date Start date
P

Phil Latio

Quick question.

I have imported a column of text and there is annoying space before the
first letter on most lines.

Is it even possible to write some sort of macro that will search highlighted
fields and delete this space if it is the first character (assuming a space
is classed as a character in Excel)? If so, how difficult is this?

Cheers

Phil
 
Try this macro...

Sub RemoveLeadingSpaces()
Dim C As Range
For Each C In Selection
C.Value = LTrim(C.Value)
Next
End Sub
 
Hi,

Since its the only extra space you could enter
=TRIM(A1)
in cell B1 and fill it down by double clicking the fill handle.

This function removes all leading and trailing spaces and all but one space
between each word.

If that might do something you don't want you can use this formula:
=IF(LEFT(A1,1)=" ",MID(A1,2,1000),A1)
 
Back
Top