Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete Leading and Trailing spaces (Excel 97)

    Hi All,

    How would I write a macro that will allow me to delete all leading and trailing spaces in all cells in columns A and B?

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Delete Leading and Trailing spaces (Excel 97)

    Try this

    Sub TrimCells()
    Dim oCell As Range
    For Each oCell In [A:B].SpecialCells(xlCellTypeConstants, 2)
    oCell = Trim(oCell)
    Next
    End Sub

    Andrew C

  3. #3
    Lounger
    Join Date
    Apr 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Leading and Trailing spaces (Excel 97)

    Thanks for your help. It worked perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •