Results 1 to 5 of 5

Thread: Stripping spaces from a number in Excel ...

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Resolved Stripping spaces from a number in Excel ...

    I've got a column of numbers.
    Each number is 19 digits long, and there are NO leading zeros.

    Unfortunately, these numbers have intermittent spaces in the middle of them which I need to strip out.

    e.g. 292 393 67675363 98769

    I tried using the INSTR function, but that was giving me some weird results.

    This is pretty urgent, so any input would be greatly appreciated.

    Cheers

    Steve


    p.s. I have posted in the VBA forum, but I need an answer pretty quick and no-one is in there
    Last edited by TheBionicOrange; Oct 11th, 2004 at 03:20 AM.

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    G'Day TheBionicOrange,

    Can you use Replace whilst iterating past each Row, like:
    VB Code:
    1. MsgBox Replace("292 393 67675363 98769", " ", "")




    Bruce.

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Steve,

    This will iterate past Column A and do all used rows:
    VB Code:
    1. Dim intRowMax As Integer, intRowIdx As Integer
    2.  
    3. intRowMax = ActiveSheet.UsedRange.Rows.Count
    4.  
    5. For intRowIdx = 1 To intRowMax
    6.      ActiveSheet.Range("A" & intRowIdx).Value = Replace( ActiveSheet.Range("A" & intRowIdx).Value, " ", "")
    7. Next




    Bruce.
    Last edited by Bruce Fox; Oct 11th, 2004 at 03:01 AM.

  4. #4

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Cheers Bruce (why am I now thinking of Finding Nemo !!!)

    Always tend to overlook the obvious when I'm in a flap


    [edit] Thanks for that extra bit too [/edit]

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Know what you mean

    Good to see you back on the ol (VB) forum.



    Cheers,
    Bruce.

Posting Permissions

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



Click Here to Expand Forum to Full Width