+ Reply to Thread
Results 1 to 24 of 24

Calculate total hours scheduled each hours of the day

  1. #1
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Calculate total hours scheduled each hours of the day

    Hi All - somewhat of a newbie and I get most of my learnings reading forums to solve complex (to me) problems. I have been searching and cannot find a solution and most that I find or much more advanced than I am.

    Based on a set of employee schedules, I have to figure out how many total hours are scheduled each hour. The shifts may cross midnight and they may not. The date is not relevant for this. I can figure out how to count number of employees in each hour of the day, but I would like to know how many 'hours' fall into each hour of the day.

    Row 1 = hours of the day
    Column A = Start Time
    Column B = Stop Time

    10:30p - 7a
    5:00a - 1:30pm

    10Pm hour should give me 30 minutes
    11pm hour should give me 60 minutes
    6am hour should give me 120 minutes

    ETC...


    I think I have a sourced a formula that will work but it only works for times that do not cross midnight, and even those results look incorrect but at least there is data.

    Can this be done? What is the obvious that I am overlooking? Or am I overthinking this and it can be done simply by headcount in each hour?
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    Hi, welcome to the forum, and just to point out that explanation is everything, there is only one hour to the hour
    many total hours are scheduled each hour
    But this aside, when time crosses midnight all you have to do is add an if condition to your formula.
    To check if the next hour is after midnight is count the hours until midnight and that is not 00:00:00 or 24:00:00 (because that is 0 too) but take it to 23:59:59.9 and the remaing time aftter this you just add to the previous result.
    I'll download your file and take a look but this will give you an idea how to approach this.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    Just took a look at your file and table, if you want a headache, you're on the right track.

    You've got columns A and B which I assume are the start of probably a shift and B the end of that shift
    On the first row, the header, you have the have the full day in 24 hours in one-hour columns
    For a 'normal' shift starting somewhere in the day and ending before midnight, that's understood but now comes the issue
    If a shot starts at 10:00 PM and ends at 07:00 AM YOU DON'T HAVVE THE COLUMNS FOR THAT.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    In the attached try this in C2 filled down and across. Yields minutes
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  5. #5
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Calculate total hours scheduled each hours of the day

    Oh My Gosh! Yes this is exactly what I was trying to accomplish.

    I did as you suggested in C2 and got an error (attached)
    Attached Images Attached Images

  6. #6
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Calculate total hours scheduled each hours of the day

    I agree I have a headache. The formula did not error out, it simply returned zero.
    You are correct Column A = Start Time and Column B = End Time.

  7. #7
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Calculate total hours scheduled each hours of the day

    Quote Originally Posted by Trippi View Post
    Oh My Gosh! Yes this is exactly what I was trying to accomplish.

    I did as you suggested in C2 and got an error (attached)
    Think I figured it out. SEQUENCE is not an available function for me in Office but I do have it on Office365. Going to work with this some more. MANY THANKS!

  8. #8
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Calculate total hours scheduled each hours of the day

    I guess I'm not understanding this correctly (which is fine), but shouldn't C2 yield 59 minutes? from 10:30pm - 7am goes across 12am so wouldn't that all be included there? Wouldn't D2:I2 also have 59 as values (etc.)?

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    Well, if I may intrude (again) 59 is not a full hour, I cannot alter the formula because my version does not support the sequence function but I would suggest to try the following:

    Please Login or Register  to view this content.
    Like I said I don't know if this will work but ...

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    Thank you Keebellah. I will check it out.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    OK. This should take care of the minutes issue. I was having trouble defining the bins argument in FREQUENCY.

    In the attached find a second time header to set the boundaries of the bins. In row 2 this formula to set the upper boundaries so FREQUENCY counts only the times less than or equal to the upper boundary without counting the next hour itself.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Adjustments for the lower boundary (greater than) are made in the last formula. In C3 down and across to return hours.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    To return minutes as before
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 04-28-2021 at 03:55 AM.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    Quote Originally Posted by Trippi View Post
    Think I figured it out. SEQUENCE is not an available function for me in Office but I do have it on Office365. Going to work with this some more. MANY THANKS!
    If you would like a non 365 version please let me know.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    IMHO the table does not show the correct count when you start at 22:30 (10:30 PM) and end at 07:00 the next morning the count should be (8 * 60) + 30 but since you do not use dates you don't know this.
    I would do for a Gantt-like chart that starts dynamically at midday previous day and ends at the current day midnight, that way you can visualize the actual shifts as they go
    You can then even create a monthly report using a slicer
    But, that will require or VBA (macros) or an extended formula with many helper columns to account for all options.

  14. #14
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Calculate total hours scheduled each hours of the day

    I am amazed at everyone's knowledge and willingness to help. This has been a huge lifesaver and time saver. I understand the over midnight issue. I purposely left the dates off (would have been too complicated for the audience) but under normal circumstances they do exist. I would be happy to supply the data set with dates if you wanted the challenge.

  15. #15
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Calculate total hours scheduled each hours of the day

    Quote Originally Posted by FlameRetired View Post
    If you would like a non 365 version please let me know.
    That would be much appreciated - thank you!

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    Me too, we learn too from other's questions and helping out, challenges are always interesting

  17. #17
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    Here is a non 365 formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    @FlameRetired: formula doesn't work with my 2016

  19. #19
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    You may have to array enter this one. Office 365 renders me 'blind' to that need.

    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    I tried that too but for some reason it still doesn't work, no issue, if the OP has the solution, I'm happy

  21. #21
    Registered User
    Join Date
    10-23-2020
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Calculate total hours scheduled each hours of the day

    I was able to get the non 365 formula to work with a straight copy paste. First i did a copy paste to make sure I wasn't able to use SEQUENCE - got the #NAME? error. Then I took the new formula and did a copy past and the error went away and I was able to update the entire sheet.

    I will say it again...blown away by the generosity and smarts! THANK YOU!

  22. #22
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    Quote Originally Posted by Keebellah View Post
    I tried that too but for some reason it still doesn't work, no issue, if the OP has the solution, I'm happy
    Nope. Not letting me off that easily.

    File attached. You want sheet count(6). I had several ideas going at once.

  23. #23
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Calculate total hours scheduled each hours of the day

    Nice
    And I'm not letting off that easily either, since you're missing the midnight to noon of the following day

  24. #24
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Calculate total hours scheduled each hours of the day

    Thank you.

    The problem was in the formulas I used in the headers. The cumulative adding of times pushed those times into another (the next) day (face in palm).

    Formula in D1 and across should be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and in D2
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The 2:00 AM → 11:00 AM time slot fills in at rows 12:14 starting at column AC.
    Last edited by FlameRetired; 04-30-2021 at 03:16 PM.

+ 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] Formula to calculate hours worked w/lunch or w/o + OT column only total after 40 hours
    By blinhart in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-31-2023, 11:14 AM
  2. Replies: 5
    Last Post: 09-12-2019, 04:16 AM
  3. [SOLVED] Calculate meal periods based on total scheduled hours
    By Motoxboi26 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-13-2018, 02:52 AM
  4. Total the hours scheduled
    By kabshire4608 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 01-06-2010, 03:59 PM
  5. scheduled hours total
    By Jeff Desruisseaux in forum Excel General
    Replies: 1
    Last Post: 07-01-2005, 07:05 AM
  6. scheduled hours total
    By Jeff Desruisseaux in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2005, 07:05 AM
  7. [SOLVED] scheduled hours total
    By Jeff Desruisseaux in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-01-2005, 07:05 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