+ Reply to Thread
Results 1 to 13 of 13

Finding date groups

  1. #1
    Registered User
    Join Date
    07-08-2008
    Location
    Arkansas
    Posts
    32

    Finding date groups

    I need to find the date groups from a series of dates in a row. As you can see below, I have a series of dates that come from an On-Call schedule using the Macro below. What I need it to do is look at the string of dates and pull out the newest and the oldest dates for each time period, example:

    From the dates below, I need it to display the dates like this:
    Columns A B C
    Person 1 1/10/2013 To 1/16/2013 1/24/2013 To 1/30/2013 3/21/2013 To 3/27/2013
    Person 2 1/10/2013 To 2/9/2013

    Person 1 Schedule all in one row in a cell each
    1/10/2013 1/11/2013 1/12/2013 1/13/2013 1/14/2013 1/15/2013 1/16/2013 1/24/2013 1/25/2013 1/26/2013 1/27/2013 1/28/2013 1/29/2013 1/30/2013 3/21/2013 3/22/2013 3/23/2013 3/24/2013 3/25/2013 3/26/2013 3/27/2013

    Person 2 Schedule all in one row in a cell each
    1/10/2013 1/11/2013 1/12/2013 1/13/2013 1/14/2013 1/15/2013 1/16/2013 1/17/2013 1/18/2013 1/19/2013 1/20/2013 1/21/2013 1/22/2013 1/23/2013 1/24/2013 1/25/2013 1/26/2013 1/27/2013 1/28/2013 1/29/2013 1/30/2013 2/1/2013 2/2/2013 2/3/2013 2/4/2013 2/5/2013 2/6/2013 2/7/2013 2/8/2013 2/9/2013

    I do not need the dates in-between the dates populated in a cell, all I want is just to split out the beginning and the end dates.

    Is this possible to do?
    I am working with Excel 2007
    Thank you for your time!



    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Finding date groups

    Can't you simply use a formula such as:
    =Min(A1:U1)
    =Max(A1:U1)

    ??

  3. #3
    Registered User
    Join Date
    07-08-2008
    Location
    Arkansas
    Posts
    32

    Re: Finding date groups

    There are multiple times within the string of dates that the person is on call. Everyday the person is on-call the code adds it to the list (row). Take for instance person one; they are on call 1/10/2013 To 1/16/2013, 1/24/2013 To 1/30/2013, 3/21/2013 To 3/27/2013 and several other times. I need the code or formula to look through the entire row and pull out the groups of dates that go together as shown above.

    Is this do able?

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Finding date groups

    PL TRY THIS CODE.
    Sheet1 contains data from 2nd row.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-08-2008
    Location
    Arkansas
    Posts
    32

    Re: Finding date groups

    kvsrinivasamurthy,

    I was unable to get the code to achieve the results I need so I have up loaded a copy of the file with the data. On Sheet1 is the output data from the code "Sub aaa()" shown below and Sheet2 is the desired output I am looking for each row of dates. Do I need to have each output to a separate sheet or will the output go to one sheet?

    Thank you for your help

    Book2 .xlsm

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Finding date groups

    Try this one
    Please Login or Register  to view this content.
    Last edited by AB33; 01-24-2013 at 04:28 AM.

  7. #7
    Registered User
    Join Date
    07-08-2008
    Location
    Arkansas
    Posts
    32

    Re: Finding date groups

    AB33,

    Very Close! The code ran and produced the following on sheet 2 starting at A2:

    1/1/2013 1/10/2013
    1/11/2013 to 1/24/2013
    1/25/2013 to 3/21/2013
    3/22/2013 to 4/18/2013
    4/19/2013 to 5/16/2013
    5/17/2013 to 6/6/2013
    6/7/2013 to 8/15/2013
    8/16/2013 to 8/22/2013
    8/23/2013 to 10/3/2013
    10/4/2013 to 10/17/2013
    10/18/2013 to 12/19/2013


    It should produce the following:


    1/1/2013 to 1/2/2013
    1/10/2013 to 1/16/2013
    1/24/2013 to 1/30/2013
    3/21/2013 to 3/27/2013
    4/18/2013 to 4/24/2013
    5/16/2013 to 5/22/2013
    6/6/2013 to 6/12/2013
    8/15/2013 to 8/28/2013
    10/3/2013 to 10/9/2013
    10/17/2013 to 10/23/2013
    12/19/2013 to 12/25/2013

    The code skipped over several dates in the series, do I need to make any changes to the sheet?

    Thank you for your time and help!

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Finding date groups

    Hello OAM,

    This macro will split the dates as described. The attached workbook has a new sheet with a button to run the macro. Here is the macro code.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Finding date groups

    OAM,
    Okay, I left out "to" from row 1, have now amended the code no 6. I do not think my code is right for this task. I thought there is a pattern to your data. I probably could not see it. For e.g in row 1 sheet 1. You have 7 days gab between the dates and suddenly in Aug, it jumps to 14 days.
    I think Leith has got it

  10. #10
    Registered User
    Join Date
    07-08-2008
    Location
    Arkansas
    Posts
    32

    Re: Finding date groups

    Leith Ross, the code works great and as I asked for! However, I left out a critical piece of information (I bet that is the first time you ever heard that) and I apologize for that but in column A there are names that go along with each the date ranges. Is there a way to associate the name on the data sheet in column A1 with the dates on the data sheet that start at column B1 and the name in column A2 with the dates that start in column B2, etc..?

    Again, I apologize for not letting you know but I was so engrossed in getting the dates sorted that I forgot to associate them to the names. The code works great and thank you for that!

    Sincerely

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Finding date groups

    Hello OAm,

    Since I don't see any names on any of the worksheets in the workbook you posted, I must assume you have a more up to date workbook. Post that one and I will make the changes needed to the macro.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Finding date groups

    Hello OAM,

    I rewrote the macro to add the names from column "A" and also decreased the running time for the macro. Here is the new macro code. This has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    07-08-2008
    Location
    Arkansas
    Posts
    32

    Thumbs up Re: Finding date groups

    Perfect!! The macro works Great!

    [SOLVED]

+ 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