+ Reply to Thread
Results 1 to 12 of 12

Calculating Hours Worked on Work Days Per Month

  1. #1
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Calculating Hours Worked on Work Days Per Month

    Hello, I have been working on an excel sheet to calculate the hours worked on a job per month, evenly distributing the hours across the correct months according to what days work was performed on. Thanks to the help of an excel guru on here I was able to get the formula working without issue. However, I was then instructed that the hours should only be spread across work days (excluding weekends/holidays). I have tried using the NETWORKDAYS() function and I know it is possible, but I still am struggling to get the hours to sum to the correct amount.

    Workdays816.png

    Pictured above is a small recreation of my data with both versions of the formula. On top is the version that works without considering work days(=MAX(0,MIN(G$1,$B3+1)-MAX(F$1,$A3))/$D3*$C3). The bottom calculation is what I have come up with to try and only account for work days (=MAX(0,NETWORKDAYS(MAX(F$8,$A10),MIN(G$8,$B10))/$D10*$C10)). As shown the "Sum" of the hours is off on the latter formula whenever the hours span across 2 or more months. I have tried tweaking the formula many times but I just can't get it to work. The issue is that the formula appears to be adding an extra day to the month before whenever the fist of the month is considered. Any help is appreciated.

    workdaysExampleNew.xlsx
    Last edited by HardlyScene; 08-16-2022 at 08:33 AM. Reason: Updated wording and workbook for clarity

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Calculating Hours Worked on Work Days Per Month

    i looked at this quickly, but shouldnt the formula for Days worked in column D be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As the days worked should only take into consideration workdays and not weekends?
    <----- If you are happy with your solution please click on the "* Add Reputation" as a way to say thank you.

  3. #3
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Re: Calculating Hours Worked on Work Days Per Month

    Quote Originally Posted by dosydos View Post
    i looked at this quickly, but shouldnt the formula for Days worked in column D be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As the days worked should only take into consideration workdays and not weekends?
    Dumb oversight on my part when recreating the problem. I have corrected the mistake and now the correct issue I was referencing is showing, for some reason I cannot figure out the hours won't correctly sum!
    Last edited by HardlyScene; 08-15-2022 at 11:17 AM.

  4. #4
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Re: Calculating Hours Worked on Work Days Per Month

    Small Update. It appears the issue (or part of it at least) is caused by the formula including a day from the previous month when the "Date Started" is the first of the month. Here is a link to the updated workbook. Hope this aids in a solution, thank you!

    workdaysExampleUpdate.xlsx

  5. #5
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Re: Calculating Hours Worked on Work Days Per Month

    Any help is appreciated, if I posted the question in the wrong forum or area please let me know!

  6. #6
    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,756

    Re: Calculating Hours Worked on Work Days Per Month

    You've had 100 views and only one offer of help - something may not be clear to those who have looked.

    Have you included expected reults in the workbook?
    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.

  7. #7
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Re: Calculating Hours Worked on Work Days Per Month

    Quote Originally Posted by AliGW View Post
    You've had 100 views and only one offer of help - something may not be clear to those who have looked.

    Have you included expected reults in the workbook?
    Thank you for the advice! I have updated the workbook in my post with a clear example of expected results. Also all the updated information that I have found on what the issue is.

  8. #8
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Calculating Hours Worked on Work Days Per Month

    I think you just need a -1, as the NETWORKDAYS function is inclusive. That is, =NETWORKDAYS(DATE(2022,8,15),DATE(2022,8,16)) will return 2 whereas =DATE(2022,8,16)-DATE(2022,8,15) will return 1. So it should be, in F10:

    =MAX(0,NETWORKDAYS(MAX(F$8,$A10),MIN(G$8-1,$B10))/$D10*$C10)

    You could also use EOMONTH instead to remove the need to always have a "next" month to refer to, like this:

    =MAX(0,NETWORKDAYS(MAX(F$8,$A10),MIN(EOMONTH(F$8,0),$B10))/$D10*$C10)

  9. #9
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Calculating Hours Worked on Work Days Per Month

    i went a nested if route:
    in F10 use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    drag across and down

  10. #10
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,419

    Re: Calculating Hours Worked on Work Days Per Month

    Try this formula in F12 and copy right
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This formula produces the same results as expected.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Re: Calculating Hours Worked on Work Days Per Month

    Quote Originally Posted by nick.williams View Post
    I think you just need a -1, as the NETWORKDAYS function is inclusive. That is, =NETWORKDAYS(DATE(2022,8,15),DATE(2022,8,16)) will return 2 whereas =DATE(2022,8,16)-DATE(2022,8,15) will return 1. So it should be, in F10:

    =MAX(0,NETWORKDAYS(MAX(F$8,$A10),MIN(G$8-1,$B10))/$D10*$C10)

    You could also use EOMONTH instead to remove the need to always have a "next" month to refer to, like this:

    =MAX(0,NETWORKDAYS(MAX(F$8,$A10),MIN(EOMONTH(F$8,0),$B10))/$D10*$C10)
    Thank you! both functions worked like a charm. I chose to use the second as it seems more linear in design without using the next month. I really appreciate your help thanks again saved me some grey hairs that's for sure.

  12. #12
    Registered User
    Join Date
    08-08-2022
    Location
    CT, USA
    MS-Off Ver
    Microsoft 365
    Posts
    11

    Re: Calculating Hours Worked on Work Days Per Month

    Just noticed dosydos and Hans responses both work great and thank you for the help!

+ 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. Calculating Hours worked per month in VBA Excel
    By HardlyScene in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-10-2022, 04:11 PM
  2. Calculating Work and worked hours using Pivot
    By rahul_ferns76 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-23-2017, 04:16 PM
  3. Replies: 8
    Last Post: 09-30-2017, 07:00 PM
  4. [SOLVED] How to work out number of 'days' worked based on total hours
    By tangcla in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-20-2016, 10:12 PM
  5. Calculating basic hours worked, between a time range and premium hours worked
    By RoyLittle0 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-07-2012, 06:59 AM
  6. Replies: 4
    Last Post: 07-15-2010, 11:48 AM
  7. Calculate Work Days Based on Hours Worked
    By FM1 in forum Excel General
    Replies: 7
    Last Post: 02-04-2009, 12:27 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