+ Reply to Thread
Results 1 to 5 of 5

Leading Zeroes to string with possible alpha parts

  1. #1
    Registered User
    Join Date
    09-16-2014
    Location
    Los Angeles, CA
    MS-Off Ver
    2010
    Posts
    5

    Leading Zeroes to string with possible alpha parts

    I need leading zeroes to numbers less than 5 numbers in length. HOWEVER some may have a letter at the end. SO, I am looking for a formula that will do:

    1 --------->00001
    12 -------->00012
    123 ------->00123
    1234 ----->01234
    12345 ---->12345
    1a -------->00001a
    12b ------->00012b
    123c ------>00123c
    1234d ----->01234d
    12345e ---->12345e

    Thanks!

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Leading Zeroes to string with possible alpha parts

    Try this formula
    in B1 and copy down

    =IF(ISNUMBER(--A1),TEXT(A1,"00000"),TEXT(LEFT(A1,LEN(A1)-1),"00000")&RIGHT(A1))

    Row\Col
    A
    B
    1
    1 00001
    2
    12 00012
    3
    123 00123
    4
    1234 01234
    5
    12345 12345
    6
    1a 00001a
    7
    12b 00012b
    8
    123c 00123c
    9
    1234d 01234d
    10
    12345e 12345e
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Leading Zeroes to string with possible alpha parts

    Using your posted data in A1:A10

    Try this formula, copied down
    Please Login or Register  to view this content.
    Actually, I can abbreviate the formula a bit more:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Last edited by Ron Coderre; 07-06-2015 at 07:39 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    09-16-2014
    Location
    Los Angeles, CA
    MS-Off Ver
    2010
    Posts
    5

    Re: Leading Zeroes to string with possible alpha parts

    Quote Originally Posted by AlKey View Post
    Try this formula
    in B1 and copy down

    =IF(ISNUMBER(--A1),TEXT(A1,"00000"),TEXT(LEFT(A1,LEN(A1)-1),"00000")&RIGHT(A1))

    Row\Col
    A
    B
    1
    1 00001
    2
    12 00012
    3
    123 00123
    4
    1234 01234
    5
    12345 12345
    6
    1a 00001a
    7
    12b 00012b
    8
    123c 00123c
    9
    1234d 01234d
    10
    12345e 12345e
    Perfect!! Thank you! This worked wonderfully.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Leading Zeroes to string with possible alpha parts

    You're welcome and thank you for the feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools -> Mark thread as Solved).

+ 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. Add zeroes within dates (NOT leading zeroes)
    By anthony19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 04:08 PM
  2. Leading Zeroes & XML
    By jlhart76 in forum Excel General
    Replies: 4
    Last Post: 06-03-2009, 08:23 PM
  3. Leading Zeroes In Decimals
    By johnph77 in forum Excel General
    Replies: 3
    Last Post: 05-15-2009, 10:04 AM
  4. [SOLVED] Leading Zeroes
    By Ken in forum Excel General
    Replies: 1
    Last Post: 10-07-2005, 11:05 AM
  5. [SOLVED] No decimals and leading zeroes
    By gcotterl in forum Excel General
    Replies: 2
    Last Post: 04-18-2005, 02:06 AM

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