+ Reply to Thread
Results 1 to 4 of 4

Format with spaces in between with specific conditions

Hybrid View

  1. #1
    Registered User
    Join Date
    07-20-2011
    Location
    Kerala, India
    MS-Off Ver
    Excel 2013
    Posts
    93

    Thumbs up Format with spaces in between with specific conditions

    Hi!

    Thank you for all the support.

    I have a column : Customer Number

    Customer Number: we have 2 types of customer numbers (12 or 13 alphanumeric)

    eg: 446828442414 (12 alphanumeric) or 8144144141442 (13 alphanumeric)

    and need them formatted according to number of digits

    If 12 alphanumeric: 00<3space>0<3space>00<3space>00<3space>00<3space>000
    i.e. : 44 6 82 84 42 414

    or if 13 alphanumeric: 000<3space>000<3space>00<6space>00<3space>0<3space>00
    i.e.: 814 414 41 41 4 42

    suggestion: IF (No. of characters = 12) use 12 alphanumeric space format

    or

    IF (No. of characters = 13) use 13 alphanumeric space format


    Appreciate your valuable time and effort
    Attached Files Attached Files

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Format with spaces in between with specific conditions

    Formula: copy to clipboard
    =if(len(a2)=12,text(a2,"00   0   00   00   00   000"),text(a2,"000   000   00      00   0   00"))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,418

    Re: Format with spaces in between with specific conditions

    You can use this in B2:

    Formula: copy to clipboard
    =IF(LEN(A2)=12,TEXT(A2,"00   0   00   00   00   000"),IF(LEN(A2)=13,TEXT(A2,"000   000   00      00   0   00"),""))

    then copy down.

    Hope this helps.

    Pete

    EDIT: Almost snap, Martin.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Format with spaces in between with specific conditions

    also if they are mixed alpha numeric
    then
    Formula: copy to clipboard
    =IF(LEN(A2)=13,LEFT(A2,3)&REPT(" ",3)&MID(A2,3,3)&REPT(" ",3)&MID(A2,7,2)&REPT(" ",6)&MID(A2,9,2)&REPT(" ",3)&MID(A2,11,1)&REPT(" ",3)&RIGHT(A2,2),IF(LEN(A2)=12,LEFT(A2,2)&REPT(" ",3)&MID(A2,3,1)&REPT(" ",3)&MID(A2,4,2)&REPT(" ",3)&MID(A2,6,2)&REPT(" ",3)&MID(A2,8,2)&REPT(" ",3)&RIGHT(A2,3),""))
    you could simply type the spaces rather than using rept(" ",3) if you want

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2012, 12:48 PM
  2. Replies: 3
    Last Post: 07-11-2012, 06:36 PM
  3. Replies: 1
    Last Post: 05-18-2006, 11:45 PM
  4. Add spaces for specific fields to paste in
    By Corey in forum Excel General
    Replies: 3
    Last Post: 12-30-2005, 06:25 PM
  5. [SOLVED] Replacing specific characters with spaces
    By Night Owl in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-13-2005, 01:06 PM

Tags for this Thread

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