+ Reply to Thread
Results 1 to 6 of 6

Output a comma separated list of inclusive years

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Output a comma separated list of inclusive years

    I'm new to the forum so bear with me.
    Given a list of beginning years and ending years, how can I create a column that gives the whole list of inclusive years separated by a comma?

    Start Year End Year List of Years
    1985 1995 1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995
    2000 2009 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009

    I'm not that familiar with VB, so if the answer is a VB script, step-by-step instructions would be great.

    Thanks so much!
    Cheers! sigmaj
    Last edited by sigmaj; 07-02-2013 at 10:31 AM.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Output a comma separated list of inclusive years

    Hi,

    Not quite sure what you mean by "The goal is to be able to do a VLOOKUP on the List of Years columns" as VLOOKUP on a string will not give you your desired results.

    Are you perhaps looking to see, given a particular year, between which set of Start and End Years that year falls between, if any?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    07-02-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Output a comma separated list of inclusive years

    Thanks XOR LX. Sorry about the confusion. I want to be able to output each inclusive year in the cell separated by something, it doesn't necessarily have to be a commma. I already have a search function set up in an existing spreadsheet dashboard that will search for a specific year. So if I type in "1996", the function searches the column for "1996" and return a number. If I type in a wildcard "199*", the function searches and returns the number of all cells that are in the 1990s. Thanks!

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Output a comma separated list of inclusive years

    Ah, then you're going to require a VBA solution for what you want since Excel's in-built funtions for concatenating strings are woeful when it comes to working with arrays of indeterminate length.

    Can I ask why these values can't be stored in separate cells in e.g. separate columns and these columns then be used for the search?

    Regards

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Output a comma separated list of inclusive years

    If it's just a count of the number of times in which a certain year falls within the list of year ranges you have, then you don' t need to concatenate anything.

    For example, if your Start Dates and End Dates are in cells A1:A100 and B1:B100 respectively, and the Year for which you want to determine the number of these ranges for which that Year falls between them is in cell D1, then:

    =SUMPRODUCT(($A$1:$A$100<=$D$1)*($B$1:$B$100>=$D$1))

    Regards

  6. #6
    Registered User
    Join Date
    07-02-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Output a comma separated list of inclusive years

    Thanks XOR LX, I'll give it a shot.

+ 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