+ Reply to Thread
Results 1 to 13 of 13

Consecutive dates to FROM and TO

  1. #1
    Registered User
    Join Date
    06-09-2016
    Location
    Northampton, England
    MS-Off Ver
    Office 365
    Posts
    14

    Consecutive dates to FROM and TO

    Hello All

    Happy New Year.

    I hope someone will be able to advise a process to achieve the below:
    I have a system where I can pull sickness data from a company - the data is in an excel format and shows the name and the date they were sick.
    If they were off consecutively each date is shown in a new row.

    I need the date to show as "from" and "to" - if it is only one date they were off the from and to date should be the same, if their sickness was consecutive it should show the first in the sequence as from and the last in the sequence as to.

    Thanks
    J
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,912

    Re: Consecutive dates to FROM and TO

    Administrative Note:

    Members will tailor the solutions they offer to the version of Office (Excel) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Consecutive dates to FROM and TO

    With helper column

    set C3=1

    in C4 and copy down

    =IF(A4=A3,IF(B4=B3+1,C3,C3+1),C3+1)

    in F3

    =INDEX($A$3:$A$1000,MATCH(ROWS($1:1),$C$3:$C$1000,0))

    in G3

    =INDEX($B$3:$B$29,MATCH(ROWS($1:1),$C$3:$C$29,0))

    in H3

    =INDEX($B$3:$B$29,MATCH(ROWS($1:1),$C$3:$C$29,0))+COUNTIFS($A$3:$A$29,K3,$C$3:$C$29,ROWS($1:1))-1
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  4. #4
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Consecutive dates to FROM and TO

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by BMV; 01-08-2022 at 09:39 AM.

  5. #5
    Registered User
    Join Date
    06-09-2016
    Location
    Northampton, England
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Consecutive dates to FROM and TO

    Hi BMV and John
    Thank you very much for the solutions - they both do exactly what I required.

    I do have a slight variation to it and have tried to modify the formulas to achieve the same result but not getting anywhere.
    I have an additional column - called shift, if there is an offday in between two sick dates - this should be considered as one episode.

    J
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Consecutive dates to FROM and TO

    From your data, the "Off Day" makes no diiference to the results as the column is not considered in the formula.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-09-2016
    Location
    Northampton, England
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Consecutive dates to FROM and TO

    Hi John

    Thanks for the quick reply.
    Apologies, I forgot to include the crucial information as there can be working days in between.
    J
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Consecutive dates to FROM and TO

    New helper in column E

    =IF($B4="WorkingDay",0,IF($B3="WorkingDay",MAX($E$3:E3)+1,IF(A4=A3,IF(C4=C3+1,E3,E3+1),E3+1)))
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-09-2016
    Location
    Northampton, England
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Consecutive dates to FROM and TO

    Works exactly as I require.
    Thank you for all the help! I am very grateful!

    J

  10. #10
    Registered User
    Join Date
    06-09-2016
    Location
    Northampton, England
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Consecutive dates to FROM and TO

    Hi John

    Apologies - found an issue.
    If an OffDay is between two WorkingDays, It's counting them as Sick Days.
    See attached - highlighted in orange.

    I spent an whole afternoon trying to understand the code, which I did but I couldn't get it to ignore the offDays.

    J
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,567

    Re: Consecutive dates to FROM and TO

    Try pasting the following into cell E4 and then double clicking the fill handle to copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  12. #12
    Registered User
    Join Date
    06-09-2016
    Location
    Northampton, England
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Consecutive dates to FROM and TO

    Thank You!

  13. #13
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,567

    Re: Consecutive dates to FROM and TO

    You're Welcome. Thank You for marking the thread as 'Solved'. I hope that you have a blessed day.

+ 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. Replies: 17
    Last Post: 02-14-2024, 07:07 AM
  2. Formula for Checking Consecutive Dates and Similar Payments on Consecutive Dates
    By Dark_Knight_897 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-23-2021, 08:34 AM
  3. [SOLVED] Sum Consecutive Dates
    By blueceb in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-21-2020, 03:08 PM
  4. Start and End Dates for Consecutive Dates
    By MissC in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-15-2017, 05:26 PM
  5. [SOLVED] Count instance of >8 days between consecutive dates in a list of dates
    By Keats713 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-07-2017, 11:18 AM
  6. consecutive dates
    By raphiduani in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-04-2013, 08:38 AM
  7. Replies: 3
    Last Post: 02-14-2012, 01:38 AM

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