Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Using VBA, i am trying to format a range of numbers as text and then remove the spaces so that a 16 digit string remains. How can I achieve this without the data distorting, see attached.

    [attachment=83193:test_remove_spaces.xls]

    Thanks
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try this:

    Code:
    Sub RemoveSpaces()
      Dim oCell As Range
      For Each oCell In Range("A1:A6")
    	oCell.NumberFormat = "@"
    	oCell = Replace(oCell, " ", "")
      Next oCell
    End Sub

  3. #3

Posting Permissions

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