+ Reply to Thread
Results 1 to 3 of 3

columns in excel to reflect array of values entered in previous two columns

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

    columns in excel to reflect array of values entered in previous two columns

    I need to write a VB Macro
    requirement is like this
    I have excel sheet
    column1=2001
    Column2=2010
    I have to make Column3 as 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010
    Another example
    PM Column1=1997
    Column2=2000
    Column should be 1997,1998,1999,2000
    I mean Column3 should be 1997,1998,1999,2000
    Last edited by netvasi; 09-16-2011 at 05:59 AM. Reason: Not complying forum rules..

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: columns in excel to reflect array of values entered in previous two columns

    A UDF can do this. For example:

    Please Login or Register  to view this content.

    Copy and paste the code into a standard module and then use it as a normal function.

    =CollateYears(A1,B1) gives 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 if A1 has 2001 and B1 has 2010.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


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

    Re: columns in excel to reflect array of values entered in previous two columns

    Thanks TMshucks..Yes it helped a lot but the first year is repeated twice ..For example..If A1 has 1995 B1 has 1997 C1 returns 1995,1995,1996,1997...means the first year is repeated..

    Also I want to know what to do if the year is entered in two digits? I have 1998 in A1 and 2001 in B1 ..For this requirement what could be the UDF..Can you please clarify as i have an excell file with 17000+ records and years are entered in two digits..

    With Regards
    Netvasi


    Quote Originally Posted by TMShucks View Post
    A UDF can do this. For example:

    Please Login or Register  to view this content.

    Copy and paste the code into a standard module and then use it as a normal function.

    =CollateYears(A1,B1) gives 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 if A1 has 2001 and B1 has 2010.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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