+ Reply to Thread
Results 1 to 16 of 16

Adding a Sequence of Consecutive Years in Between a Range of years

  1. #1
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Unhappy Adding a Sequence of Consecutive Years in Between a Range of years

    I know the title may not sound so clear so here is an example of what I trying to accomplish.

    Example:

    I have a predetermine range of years (Column A) and I want to add consecutive number in between them like (Column B)

    [Column A]
    2010-2015
    2008-2012
    2011-2015
    1998-2002
    2001-2003



    [Column B]
    2010, 2011, 2012, 2013, 2013, 2015
    2008, 2009, 2010, 2011, 2012
    2011, 2012, 2013, 2014, 2015
    1998, 1999, 2001, 2002
    2001, 2002, 2003


    I look forward to hearing back from you guys.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    --------------------Bump-----------------------------

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    You can set this up as a UDF
    Please Login or Register  to view this content.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Hi ben, welcome to the forum

    Forum rules require you to wait at least a day before bumping,

    Having said that, why does this have to all be in 1 cell? It's not like you could (easily) use any on that in a formula. Have you considered using different columns?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by FDibbins View Post
    Hi ben, welcome to the forum

    Forum rules require you to wait at least a day before bumping,

    Having said that, why does this have to all be in 1 cell? It's not like you could (easily) use any on that in a formula. Have you considered using different columns?
    Thank you! I'm sorry I did not know that. I just a a little frustrated trying to figure this issue. As for your question. It does not necessarily have to be in the same column it can be in multiple columns as long as I'm able to add the years in between within columns is fine and can later group them together with commas.

    i can't seem to be able to create the the consecutive years in between the predetermine range of years

  6. #6
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by dflak View Post
    You can set this up as a UDF
    Please Login or Register  to view this content.
    Thank you for taking your valuable time to address my question. I'm total unexpired when it comes to excel. Can you kindly elaborate as to how can i apply this function. Do I just select the columns that i want to split the years and apply the UDA?

    Thanks,
    Benjamin

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    I have done this with a bunch of helper columns, that you can hide if needed...
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    2010-2015 2010,2011,2012,2013,2014,2015
    2010
    2015
    2010
    2011
    2012
    2013
    2014
    2015
    2
    2008-2012 2008,2009,2010,2011,2012
    2008
    2012
    2008
    2009
    2010
    2011
    2012
    3
    2011-2015 2011,2012,2013,2014,2015
    2011
    2015
    2011
    2012
    2013
    2014
    2015
    4
    1998-2002 1998,1999,2000,2001,2002
    1998
    2002
    1998
    1999
    2000
    2001
    2002
    5
    2001-2003 2001,2002,2003
    2001
    2003
    2001
    2002
    2003

    B1=SUBSTITUTE(TRIM(E1&" "&F1&" "&G1&" "&H1&" "&I1&" "&J1&" "&K1&" "&L1&" "&M1)," ",",")
    C1=IFERROR(--LEFT(A1,4),"")
    D1=IFERROR(--RIGHT(A1,4),"")
    E1=C1
    F1=IFERROR(IF(E1+1>$D1,"",E1+1),"")....copied across as needed

    Then copy that whole mess down as far as you need. Then hide columns C:??

  8. #8
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by FDibbins View Post
    I have done this with a bunch of helper columns, that you can hide if needed...
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    2010-2015 2010,2011,2012,2013,2014,2015
    2010
    2015
    2010
    2011
    2012
    2013
    2014
    2015
    2
    2008-2012 2008,2009,2010,2011,2012
    2008
    2012
    2008
    2009
    2010
    2011
    2012
    3
    2011-2015 2011,2012,2013,2014,2015
    2011
    2015
    2011
    2012
    2013
    2014
    2015
    4
    1998-2002 1998,1999,2000,2001,2002
    1998
    2002
    1998
    1999
    2000
    2001
    2002
    5
    2001-2003 2001,2002,2003
    2001
    2003
    2001
    2002
    2003

    B1=SUBSTITUTE(TRIM(E1&" "&F1&" "&G1&" "&H1&" "&I1&" "&J1&" "&K1&" "&L1&" "&M1)," ",",")
    C1=IFERROR(--LEFT(A1,4),"")
    D1=IFERROR(--RIGHT(A1,4),"")
    E1=C1
    F1=IFERROR(IF(E1+1>$D1,"",E1+1),"")....copied across as needed

    Then copy that whole mess down as far as you need. Then hide columns C:??
    Thank you for your valuable time. I think there was a misunderstanding or maybe i did not understating so well.

    So here is the range of years I currently have (Example)

    [Column A]
    2010-2015
    2008-2012
    2011-2015
    1998-2002
    2001-2003

    I need to convert Column A into the Column B

    [Column B]
    2010, 2011, 2012, 2013, 2013, 2015
    2008, 2009, 2010, 2011, 2012
    2011, 2012, 2013, 2014, 2015
    1998, 1999, 2001, 2002
    2001, 2002, 2003

    Is there a way I can attach the file so you can have a better idea

    Thanks

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    That is what I did. If you look at column B, this gives you what you said you wanted.

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    To use the UDF in cell B2 for example =SplitYears(A2)

  11. #11
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,297

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    In cell C1 to put a formula and drag to the right and down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by FDibbins View Post
    That is what I did. If you look at column B, this gives you what you said you wanted.


    Thank you it works, but the only issue is that i have over 5000 set of years that i need to arrange and they all vary their START and END year which mean I will have adjust the formula manually for it to work

  13. #13
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by Czeslaw View Post
    In cell C1 to put a formula and drag to the right and down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thank you for your time. I also tried this and it only gives me the first starting year of the column

  14. #14
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by dflak View Post
    To use the UDF in cell B2 for example =SplitYears(A2)
    Thank you so much for your valuable time I also tried this and when I apply the UDF it does not work it gives me this error #NAME?

    Would it be easier if i have the starting YEAR and END in two different columns? Because I have them in that format as well. The years can be in different columns as long I get the sequence of years withing the START year and END year.

    I'm attaching the years. One file is with the START and END in one column. The other file is with the START and END year in different columns.
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,297

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Attached is an example.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    12-17-2015
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Adding a Sequence of Consecutive Years in Between a Range of years

    Quote Originally Posted by Czeslaw View Post
    Attached is an example.
    Thank you so much this one seem to work perfectly. Thank you so much once again!!!

+ 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. [SOLVED] How to Format Dates to Colors, That Are Over 1 Year, 2 Years, and 3+ Years
    By KAB923 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-03-2015, 10:46 AM
  2. Need to expand a range of years to individual years
    By chrissandu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-26-2013, 10:46 AM
  3. [SOLVED] Age based on DOB; Accounts for leap years. Years old if >2, Months if <2 years old.
    By sharpmel in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-17-2013, 04:20 PM
  4. Replies: 2
    Last Post: 10-16-2012, 11:40 AM
  5. Select companies only if they are present for two consecutive years.
    By leydzzz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-21-2012, 11:20 AM
  6. Replies: 4
    Last Post: 11-19-2010, 11:17 AM
  7. Replies: 1
    Last Post: 12-05-2005, 08:35 AM

Tags for this Thread

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