+ Reply to Thread
Results 1 to 6 of 6

Function for Listing of years in two digits

  1. #1
    Registered User
    Join Date
    09-16-2011
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003
    Posts
    4

    Function for Listing of years in two digits

    Anybody help me in this

    I have attached an example file

    I have 98 in C3 and 02 in D3 i want E3 to display like 98,99,00,01,02 (as two digit range of years with both 98(lower limit) and 02(upper limit included...)

    Is there any formula to do this or macros?
    Attached Files Attached Files

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Function for Listing of years in two digits

    netvasi,

    Attached is a modified version of your sample workbook. In a standard module, it contains the following UDF:
    Please Login or Register  to view this content.


    In Cell E2 is the formula (which is then copied down):
    =YearList(C2,D2)

    Hope that helps,
    ~tigeravatar

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Function for Listing of years in two digits

    FYI, there is no need for that to be volatile.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    09-16-2011
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Function for Listing of years in two digits

    Thanks tigeravtar and romper that helps a lot but in my worksheet years are entered with preceding zeros
    like 01 , 02

    Can u make it work in above scenerio too pls?

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Function for Listing of years in two digits

    @netvasi: Confirmed that it still works with preceding 0's, even if the years are formatted as text. Did you give it a try?

    @Romperstomper: thanks for the info, I'll read more up on it. I've just gotten used to putting it in every UDF, hehe

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Function for Listing of years in two digits

    You only need to make it volatile if it depends on data that is not input as an argument to the function.

+ 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