+ Reply to Thread
Results 1 to 6 of 6

Formatting query, incremental values with leading zeros

  1. #1
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    39

    Formatting query, incremental values with leading zeros

    Hi all,

    I'm tracking weeks by weeknumber in the format YY-WW. At the moment I am entering the weeks manually in a general cell, preceeded by a '. I would prefer to have the sheet work out the weeks for me as we move the sheet every week. I would like to format the initial cell as follows:

    09-08 (or '09-08 if I must)
    then have the next cell in sequence read 09-09, 09-10, and so on. With the initial week in cell A3, I have tried to accomplish this with:

    =LEFT(A3,3)&RIGHT(A3,2)+1

    However, this does not work for weeks 01 through 09 because excel kills the leading zero in the second part of the formula, regardless of how I format the cell (format 00-00 does not work.) How can I force Excel it to keep the leading zero in the week number?
    Last edited by shockeroo; 04-08-2009 at 08:30 AM.

  2. #2
    Forum Contributor mubashir aziz's Avatar
    Join Date
    03-18-2009
    Location
    Lahore, Pakistan
    MS-Off Ver
    MS Office 2013
    Posts
    533

    Re: Formatting query, incremental values with leading zeros

    Suppose your data is in Row A ......


    =RIGHT(YEAR(A1),2)&"-"&WEEKNUM(A1,2)
    Attached Files Attached Files
    Last edited by mubashir aziz; 04-08-2009 at 07:22 AM. Reason: Attaching File

  3. #3
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    39

    Re: Formatting query, incremental values with leading zeros

    Thanks, but that still results in week number 09-2, 09-3 etc.

    I need it to display as 09-02, 09-03 etc. Any ideas?

  4. #4
    Forum Contributor mubashir aziz's Avatar
    Join Date
    03-18-2009
    Location
    Lahore, Pakistan
    MS-Off Ver
    MS Office 2013
    Posts
    533

    Re: Formatting query, incremental values with leading zeros

    Here we go ......... insert this formula in the sheet IN CELL A3


    =RIGHT(YEAR(A1),2)&"-"&TEXT(WEEKNUM(A1,2),"0#")

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

    Re: Formatting query, incremental values with leading zeros

    =left(aA3,3)&text(right(A3,2)+1,"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

  6. #6
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    39

    Re: Formatting query, incremental values with leading zeros

    Thanks very much all!

+ 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