+ Reply to Thread
Results 1 to 9 of 9

add space between numbers

  1. #1
    Registered User
    Join Date
    04-22-2012
    Location
    TN
    MS-Off Ver
    Excel 2003
    Posts
    22

    Question add space between numbers

    I need a macro to add a space between numbers in col A. Each number in col A is always 13 characters in length. I need to insert a space after character 9 and another space after character 12. The original number is in this format xxxxxxxxxxxxx and I need all rows in col A to be in this format xxxxxxxxx xxx x. Any help you can give is greatly appreciated, thank you.
    Last edited by love2waltz; 04-22-2012 at 08:46 AM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: add space between numbers

    Is this a one-off job, or something you have to do regularly?

    Also, are all of the values in col A numeric? If so you can do this just using a custom format.

  3. #3
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: add space between numbers

    You could do it without a macro:

    =LEFT(A1,9)&" "&MID(A1,10,3)&" "&RIGHT(A18,3)
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  4. #4
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: add space between numbers

    Re: format xxxxxxxxx xxx xx
    9 + 3 + 2 = 14 and not 15

    Please Login or Register  to view this content.
    Last edited by StevenM; 04-22-2012 at 08:22 AM.

  5. #5
    Registered User
    Join Date
    04-22-2012
    Location
    TN
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: add space between numbers

    I do this about once a month, oh, I made a mistake in my original post, I've since corrected it. Thanks for your help.

  6. #6
    Registered User
    Join Date
    04-22-2012
    Location
    TN
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: add space between numbers

    Hi soren,

    I understand the left (a1,9) and the cancatenation to add the spaces, but I don't understand the 3 in mid functin and the 18 and 3 in the right function. could you please explain? Thank you,

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: add space between numbers

    The A18 in his suggestion is a typo - he meant A1
    The 3 is the number of characters to pull from A1 (starting with the 10th character)
    http://www.excelfunctions.net/MidFunction.html

  8. #8
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: add space between numbers

    Quote Originally Posted by Cutter View Post
    The A18 in his suggestion is a typo - he meant A1
    Ahh, yes. Thanks Cutter; it should have looked like this:

    =LEFT(A1,9)&" "&MID(A1,10,3)&" "&RIGHT(A1,1) where you replace A1 with the first of you cells containing the string, and then copy it down. You could then copy/paste-values on top of your original data, or use the new string for the following computations.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: add space between numbers

    Or

    =REPLACE(REPLACE(A1,10,," "),14,," ")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1