+ Reply to Thread
Results 1 to 11 of 11

Calculating the time elapsed between two times when there is lunch and two breaks included

  1. #1
    Registered User
    Join Date
    03-19-2014
    Location
    Finland
    MS-Off Ver
    Excel 2013
    Posts
    5

    Calculating the time elapsed between two times when there is lunch and two breaks included

    Hi all,

    I am creating a worksheet for my production line to calculate the time elapsed between points that the line takes a step forward.

    The problem is that I need a formula what calculates time elapsed and takes notice of the lunch and coffee breaks and also the start time and the end time of the work day.

    Please find attached the workbook. I think it will describe my problem clearly.

    Thanks a lot for any help and answers! Please ask if you need a better description of the problem.
    Attached Files Attached Files
    Last edited by decubal; 03-31-2014 at 01:09 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    I started working on formula (as the subforum heading suggests, but it quickly started to grow. So gave up and prepared short UDF - a small macro which can be used the same way as build-in functions. The only difference is that macros have to be enabled in excel.

    Have a look on attached file and code below. I tried to use self explanatory variable names.

    calling function can be seen in the spreadsheet - first argument is relative address of the registered time, and two other are ranges with absolute addresses of work start-end and breaks (you are no longer limited to 3 ;-) ).

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Best Regards,

    Kaper

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

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Pl see attached file with formula.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Please Login or Register  to view this content.
    Wow, that's impressive.
    Of course there are repeating parts, but anyway.
    One minor comment - it does not take care of (I dont know if it happens in real data) hours after K3 (Work Ends).

  5. #5
    Registered User
    Join Date
    03-19-2014
    Location
    Finland
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Thanks guys, you are awesome! Big big thanks to both of you

  6. #6
    Registered User
    Join Date
    03-19-2014
    Location
    Finland
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Quote Originally Posted by Kaper View Post
    I started working on formula (as the subforum heading suggests, but it quickly started to grow. So gave up and prepared short UDF - a small macro which can be used the same way as build-in functions. The only difference is that macros have to be enabled in excel.

    Have a look on attached file and code below. I tried to use self explanatory variable names.

    calling function can be seen in the spreadsheet - first argument is relative address of the registered time, and two other are ranges with absolute addresses of work start-end and breaks (you are no longer limited to 3 ;-) ).
    Hi Kaper,

    I have one further question: I would like to add a column to the table where I can mark a time when the first work station gets it's work ready. Then the time elapsed between a line movement (or a day start) and the first ready workstation should be calculated like now the time between line movements. Please check the attached worksheet for clarification. I tried to use that formula/macro you posted earlier but that doesn't seem to work properly. I'm sorry if this is a dumb question - I'm just not very familiar with the macros.

    I appreciate your help!

    BR,
    decubal
    Attached Files Attached Files

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Hi,

    First what I noticed is that you now have time and date not in adjacent columns but separate.
    A minor modification shall be applied to show the UDF where are dates located, for instance passing this by additional argument:

    Please Login or Register  to view this content.
    it can be used then in calculation of starttime:
    Please Login or Register  to view this content.
    of course, as the name of the function is now different, it assigning result to function name lines have to reflect this:
    Please Login or Register  to view this content.
    F3 formula shall read:
    Please Login or Register  to view this content.
    and copy down
    in D3 you can either leave old version (if in VBA module you fave both functions) or use (if only nev version is in module).
    Please Login or Register  to view this content.
    This does not address the issue you have shown in comments - I'm a bit "slow thinker", so write in "big letters" like:
    time in F5 shall be 110 because it is the same day (B4 and B5), takes start time from .... and end time from E5(?) and includes all breaks in between.

    whole code is:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-19-2014
    Location
    Finland
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Quote Originally Posted by Kaper View Post
    This does not address the issue you have shown in comments - I'm a bit "slow thinker", so write in "big letters" like:
    time in F5 shall be 110 because it is the same day (B4 and B5), takes start time from .... and end time from E5(?) and includes all breaks in between.
    I try to clarify what I want to be calculated in column F:

    - Time in F3 shall be 93 because it is the first of the day and therefore takes start time from M3 (7:00) and end time from E3 and includes all breaks in between
    - Time in F4 shall be 115 because it is the same day (B3 and B4), takes start time from C3 and end time from E4 and includes all breaks in between
    - Time in F5 shall be 110 because it is the same day (B4 and B5), takes start time from C4 and end time from E5 and includes all breaks in between

    etc.

    So the F column should give the time difference between the times in column E and C (E comes always first) and notice the possible breaks and day changes.

    I hope this cleared the point for you?

  9. #9
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Hi,
    I rewrote somewhat the function to make it a bit more universal. So the function now expects just start time, end time and breaks (as a range).
    There is also optional argument if end of break is given as time not as length of break (minutes).

    Checking if it is the first tast that day or if the end is not after scheduled end of the workday is done with standard excel functions. This allows for quite flexible data layout and possible reause of the function in several other cases.

    so it is called now in F3 as:
    Please Login or Register  to view this content.
    if end time is empty result is empty
    as starttime we take either time from row above or standard workdaystart IF(B3=B2,C2,$M$3)
    as endtime either real endtime or workday end - whichever is earlier MIN(E3,$N$3)

    See attached file, and the code of UDF is as follows:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-19-2014
    Location
    Finland
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Thank you so much Kaper - that is exactly what I needed! You've been a great help. I appreciate your expertise.

    BR,
    decubal

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Calculating the time elapsed between two times when there is lunch and two breaks incl

    Glad to hear that.

    As the minutes_skipping_breaks is now rather universal, I'll probably refer to this thread if someone has similar problem.

    Just for easier search: several breaks during period of time stops deduct deducted

+ 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. Excel 2007 : Calculating all lunch breaks in Timesheet
    By italiansun in forum Excel General
    Replies: 0
    Last Post: 11-02-2011, 05:37 PM
  2. Subtracting lunch breaks from different shift times
    By badger in forum Excel General
    Replies: 6
    Last Post: 08-31-2011, 12:45 PM
  3. Calculating time, potential lunch break
    By B1123 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-13-2008, 09:18 AM
  4. Replies: 2
    Last Post: 08-07-2008, 05:22 AM
  5. calculate elapsed time between dates and times
    By Jenna in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2006, 12:45 PM

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