+ Reply to Thread
Results 1 to 4 of 4

Excel Leading Zeros

  1. #1

    Excel Leading Zeros

    Hi,

    I'm recreating a "transID" made up of year,month, date,branch,
    transaction number in the mainframe. The excel data contains all these
    fields, but I've had to use format>cells>custom>00000 to ensure the
    transaction number has leading zeros.

    I'm trying to concatenate these fields, but the transaction number
    reverts back no leading zeros, so what should be 2006010511100123,
    looks like 200615111123.

    I need to exactly replicate the "transID"

    Any ideas ?

    Rich


  2. #2
    Dave Peterson
    Guest

    Re: Excel Leading Zeros

    Build it up in pieces formatting each piece the way you want:

    dim myStr as string
    mystr = format(myYear,"0000") & _
    format(mymonth,"00") & _
    format(myday,"00") & _
    and so on....

    If that date is one field, you could use:
    mystr = format(mydate,"yyyymmdd") & _
    and so on...

    If you're using worksheet formulas:

    =text(a1,"yyyymmdd")&text(b1,"0000")&....



    [email protected] wrote:
    >
    > Hi,
    >
    > I'm recreating a "transID" made up of year,month, date,branch,
    > transaction number in the mainframe. The excel data contains all these
    > fields, but I've had to use format>cells>custom>00000 to ensure the
    > transaction number has leading zeros.
    >
    > I'm trying to concatenate these fields, but the transaction number
    > reverts back no leading zeros, so what should be 2006010511100123,
    > looks like 200615111123.
    >
    > I need to exactly replicate the "transID"
    >
    > Any ideas ?
    >
    > Rich


    --

    Dave Peterson

  3. #3
    Registered User
    Join Date
    01-17-2006
    Posts
    5
    I just tried your example, and found that if I enter the information as text (with a leading apostrophe) it works just fine. It also works if you format the cells as text. But then you'll need to find a way to insert the appropriate number of leading zeroes. I'll putz around and see if I can come up with something.

  4. #4
    pinmaster
    Guest

    RE: Excel Leading Zeros

    Try something like this:

    =TEXT(YEAR(NOW())&TEXT(MONTH(NOW()),"00")&TEXT(DAY(NOW()),"00")&A1&B1,"0000000000000000")

    HTH
    JG

    "[email protected]" wrote:

    > Hi,
    >
    > I'm recreating a "transID" made up of year,month, date,branch,
    > transaction number in the mainframe. The excel data contains all these
    > fields, but I've had to use format>cells>custom>00000 to ensure the
    > transaction number has leading zeros.
    >
    > I'm trying to concatenate these fields, but the transaction number
    > reverts back no leading zeros, so what should be 2006010511100123,
    > looks like 200615111123.
    >
    > I need to exactly replicate the "transID"
    >
    > Any ideas ?
    >
    > Rich
    >
    >


+ 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