+ Reply to Thread
Results 1 to 23 of 23

Complex timesheet template!

  1. #1
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Complex timesheet template!

    Hi all!



    I’ve got a complex billing template and would like automate the calculation of hours as much as possible, wondering if anyone can help take a look? J



    The grey area is where should be calculated by formula and it will be calculated based on the hours spent on task A and B within a day.



    Total regular hours is 8 hours for a day. After 8 hours, no matter what task I’m performing, all OT hours will fall to that particular task. For example, I worked on Task A from 9 am-12 pm, 1 pm-6 pm, and then had overtime work on Task B from 6-7pm, then my OT hour would fall to Task B (1 Hour), and if I worked on Task A again from 7-8pm, then there would be 1 hour OT for task A as well.



    I have got the basic formula of calculating normal hour and OT hour per task, but I cannot figure out how to calculate the total hours based on the timeline of both tasks.



    And for Saturday and Sunday, it is by default calculated as overtime hrs but sometimes it may be counted as regular hours if that day is an official working day. I’ve searched online and found out we can add a button (or any other better methods! J) to be clicked on to calculate base on different rate. Wondering if that’s possible to do this on the template (though it’s for the regular/OT hrs)?

    Thank you!!
    Attached Files Attached Files

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Complex timesheet template!

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    As you are new I will add the link for you .Please read the forum rules

    https://chandoo.org/forum/threads/ho...emplate.43747/
    https://www.mrexcel.com/board/thread...plate.1125883/

  3. #3
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Sorry for the inconvenience brought! Will take note of this, thank you!

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

    Re: Complex timesheet template!

    It appears that neither of the other sites offered a solution, so I'll make the following proposal that employs a large number of helper columns, which may be moved and/or hidden for aesthetic purposes.
    1. The merged cells in column A have been unmerged and the resulting blanks filled with the values from the cell above.
    2. Cells L2:AA15 are populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3. Cells AC2:AR15 are populated using: =IF(ISEVEN(ROW()),IF(L2<>"",SUM(MAX($AB2:AB3),1),""),IF(L2<>"",SUM(MAX($AB1:AB2),1),""))
    4. The Total Hrs column is populated using: =SUMPRODUCT(--(L2:AA2<>""))
    5. The Task A Hrs column is populated using: =IF(LEFT(A2)="S",0,SUMPRODUCT((ISEVEN(ROW()))*(AC2:AR2<=8)))
    6. The Task A OT Hrs column is populated using: =IF(AND(ISEVEN(ROW()),LEFT(A2)="S"),SUMPRODUCT(--(L2:AA2<>"")),SUMPRODUCT((ISEVEN(ROW()))*(AC2:AR2<>"")*(AC2:AR2>8)))
    7. The Task B Hrs column is populated using: =IF(LEFT(A2)="S",0,SUMPRODUCT((ISODD(ROW()))*(AC2:AR2<=8)))
    8. The Task B OT Hrs column is populated using: =IF(AND(ISODD(ROW()),LEFT(A2)="S"),SUMPRODUCT(--(L2:AA2<>"")),SUMPRODUCT((ISODD(ROW()))*(AC2:AR2<>"")*(AC2:AR2>8)))
    9. Conditional formatting is applied to in order to hide values of zero.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Thank you so much for the advice!!! Never thought of creating helper columns to calculate it >< Here are my questions regarding the formula:

    1. In Cells L2:AA15, what do '1/1440' and 'L$1+1/24' mean? and why would we need the MROUND function here?
    I've tried typing other time slots like 9:30 am or 12:30 pm, but it seems like they will not be captured in the formula (maybe it's because they are not the time slots in L1:AA1?) and will not be shown as Task A/B. Instead of adding all time slots to the template (since the person may start from 8:15 am, 8:45 am etc., so there is no specific time slot), wondering if we have other ways to revise the formula?

    2. For the zeroes hidden in the grey area, are there any ways to show zeroes if there are working hours shown in the normal or OT hours?
    For example, if a person only works on task A for 8 hours, then Task A hour will show as 8 but Task A OT hour, Task B regular hour and Task B OT hour will all be hidden now. How can we only show those hours as zeroes and keep the rest hidden? (i.e. cell H2 and I2, J3 and K3 is in pair)

    Thank you!!

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Complex timesheet template!

    Would the user be inserting rows when adding time for additional tasks on any given day?

    I suggest having a time log where the individual just adds to the next row as he/she goes along. I set one up with dropdown menus for Task and "Scheduled day?" and day of the week. The sheet automatically calculates regular and overtime hours. Then I have some pivot tables on another tab that shows OT by Task. Pivot tables can be easily reconfigured to show the data in different ways. I gave 3 examples

    In the time log, Regular Hours (Cell F2) is given by
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Overtime is given by
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ChemistB; 03-05-2020 at 03:51 PM.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

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

    Re: Complex timesheet template!

    I like ChemistB's suggestion, however in keeping with the original set up I'll offer the following which now employs two more helper ranges as compared to the file attached to post #4.
    The first helper range, rows 18:31, is populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The second helper range, rows 33:46, is populated using a similar formula except that it references cells in columns E:F as opposed to C:D.
    L2:AA15 is now populated using: =SUM(L18,L33)
    AC2:AR15 is now populated using: =IF(ISEVEN(ROW()),IF(L2>0,SUM(MAX($AB2:AB3),1),""),IF(L2>0,SUM(MAX($AB47:AB48),1),""))
    The formulas for Total Hrs through Task B OT Hrs now total the values in columns L:AA as opposed to counting cells with text.
    Note that the conditional formatting rule is removed.
    Let us know if you have any questions.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Thank you JeteMc and ChemistB! Your advice really did help a lot!! I have tested JeteMc's timesheet and found that when I put 12:30pm as break start time, and 1:30pm as break end time, the regular hrs and OT hrs show as 7 and 1 respectively. However, it should be 8 regular hrs with 0 OT hour instead. Rows for weekdays have the same issue but the current formula works well for Sat and Sun.

    Wondering if it's related to the SUMPRODUCT part of the formula? and any ways to resolve this issue?

    and sorry that I don't understand the workflow behind this formula... wondering if you would mind explaining it in more detail? Thank you so much for all the help again!

    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    Re: Complex timesheet template!

    I feel that the issue is caused by the formula in AD2:AR15
    Making the following modification seems to correct the problem (see Thursday's times): =IF(ISEVEN(ROW()),IF(M2>0,SUM(MAX($AB2:AC3),M2*24),""),IF(M2>0,SUM(MAX($AB1:AC2),M2*24),""))
    Let us know if you have any questions.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Thank you so much for your tremendous help, JeteMc!!! The template is almost perfect now!! May I ask is there any way that the template can recognize a certain weekend as a working day and calculate the working hours as per normal weekdays? (by default weekend work should be counted as OT hrs, but if it is an official working day, then it should be counted as regular hrs.)

    I've thought of adding a new tab and put the official working dates into that tab. By searching and matching with the dates
    I've tried revising it per below (I adjusted the cell reference, so it's not the same one) but it only works for one row. It seems like the logic is not right...

    C14 is the date of the weekend
    HolidayWorkingDay is the named cell range of the official working days on weekend (data list on new tab)
    For other parts, they are the same as your formula.

    =IF(VLOOKUP(C14,HolidayWorkingDay,1,FALSE)=C14,SUMPRODUCT((N14:CG14)*(CI14:FB14<=8)*24),IF(OR(B14="Interpretation (if any)",H14=""),"",IF(LEFT(A14)="S",0,SUMPRODUCT((N14:CG14)*(CI14:FB14<=8)*24))))

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

    Re: Complex timesheet template!

    Please upload an .xlsx file that illustrates the setup of this new request.

  12. #12
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Hi JeteMc! Attached please find the revised Excel template based on yours latest version

    I've added a new tab called weekend as holiday and name the cell reference as 'holidays'.

    I've tried updating the formula inside cell I4 first, but it will become #N/A if the date in column C does not exist in the holiday list.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For OT hours, I just leave as is first since not sure how to revise it (but I assume it will be the reversed version of column I?)

    Thank you so much for the help!

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

    Re: Complex timesheet template!

    See if the following yields the results you want in column I:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    See if the following works for column J:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  14. #14
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Thank you so much!! The formulae work for the template!

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

    Re: Complex timesheet template!

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

  16. #16
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Hi JeteMc, sorry for reverting back here but I noticed a few issues after trying out more examples, could you please look into the below and see if they can be revised? Thank you so much in advance!

    Bug 1: When the working hour of the day is less than 1 hour, the formula will wrong round up to 1 hour instead of reflecting the actual hour. E.g. 9:00 am time in and 9:45 am time out, the total hour is 1 hour instead of 0.75 hour. Wondering if it's related to the formula set in M20:AB48 area?



    Bug2: When the in and out times are not exactly on the hour and there's OT (e.g. in time: 9:08 PM and out time: 7:08 PM), the formula cannot accurately split the regular time as 8 and the rest as OT. Wondering if it's related columns AD:AS? since if the 8 hour cut-off point is lying in between the 2 time intervals, (e.g.7.86666, 8.866666), the sumproduct formula in column I:L can only return those hours <=8.

    Thank you!!

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

    Re: Complex timesheet template!

    Hi Fish31, hope that you are doing well. I did some work on the spreadsheet to address the bugs.
    Note that changes are made to formulas in columns H:K, L2:AB46 and AF2:AT15
    The first bug is addressed by the yellow highlighted cells in row 6 and the second by the green highlighted cells in row 9.
    Let us know if you have any questions/concerns.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Quote Originally Posted by JeteMc View Post
    Hi Fish31, hope that you are doing well. I did some work on the spreadsheet to address the bugs.
    Note that changes are made to formulas in columns H:K, L2:AB46 and AF2:AT15
    The first bug is addressed by the yellow highlighted cells in row 6 and the second by the green highlighted cells in row 9.
    Let us know if you have any questions/concerns.

    Hi JeteMc, hope you are doing well as well and really thank you so much for this!!! However, the above updated template did not include your most updated formula for the weekend days (please see your reply on Apr 2 ):

    column I:
    =IF(OR(B4="Task B",H4=""),"",IF(AND(LEFT(A4)="S",COUNTIFS(Holiday,C4)),SUMPRODUCT((M4:AB4)*(AD4:AS4<=8))*24,IF(LEFT(A4)="S",0,SUMPRODUCT((M4:AB4)*(AD4:AS4<=8))*24)))

    See if the following works for column J:
    Formula: Select Code copy to clipboard
    =IF(OR(B4="Task B",H4=""),"",IF(AND(ISEVEN(ROW()),LEFT(A4)="S"),H4-I4,SUMPRODUCT((M4:AB4)*(AD4:AS4<>"")*(AD4:AS4>8))*24))


    Not sure if it is possible to combine merge both formulae inside columns H:K? So for normal days, we can calculate those weekend work as OT hours, but if the weekend is an official working day, then the template can calculate those weekend work per normal weekday.

    Also wondering if task B formula would also be the same as task A that I can just revert back the formula range? Sorry that it is too complicated and I cannot fix it on my end..

    Thank you so much for your help again!!!!!!

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

    Re: Complex timesheet template!

    As to the formula in column I, as I was working on post #17 I realized that the formula in column H had already addressed whether or not the day in question was a Saturday or Sunday and the hours designated as regular, all I needed was to subtract the regular hours from the total for that task.
    As to the formula for column J, when I paste into cell J4 and drag up to J2 and then down to J15 I get different values than what are shown in the attachment to post #17. The values in the attachment look correct to me, if they are not please let me know what the correct values should be.
    As to combining columns H:K, I will say that in my opinion distributing the output across a wider range of cells adds to transparency as well as simplifies any modifications that may occur in the future. That said a simple solution would be to use the current set up as a helper and produce a new output table as on sheet 3 of the attached.
    It seems to me that you will have to somehow indicate how a weekend is designated as an official working day. Once that it decided then we can attempt to modify the formulas.
    Let us know if you have any questions.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Hi JeteMc,

    Thank you for your prompt reply as always!!!

    For 'combining columns H:K', what I actually meant is to combine the formulas (calculating the in and out times on the exact hour while taking the 'weekend official working day' into consideration), not combining Task A+B regular and OT hours respectively, so the current template is actually fine! I've hidden sheet1 and sheet 3 for easier reference now.

    For 'how a weekend is designated as an official working day', we would like to add a new tab named 'Weekend as holiday' and update the date in the first column. That column will be named as 'Holiday'. It is indeed implemented in your previous formula, but this formula does not return a correct total number of working hours.
    =IF(OR(B4="Task B",H4=""),"",IF(AND(LEFT(A4)="S",COUNTIFS(Holiday,C4)),SUMPRODUCT((M4:AB4)*(AD4:AS4<=8))*24,IF(LEFT(A4)="S",0,SUMPRODUCT((M4:AB4)*(AD4:AS4<=8))*24)))

    So I am wondering if we can combine the above formula and your latest formula together
    =IF(OR(B2="Task B",G2=""),"",IF(LEFT(A2)="S",0,IF(SUM(L2:AB2)>8/24,8,SUMPRODUCT((L2:AB2)*(AD2:AT2<=8))*24)))

    Please let me know if this is feasible or any info is needed, thanks a lot for your generous help again!!!
    Attached Files Attached Files

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

    Re: Complex timesheet template!

    Lets try this formula for the regular hours for Task A:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The formula for regular hours for Task B is similar.
    Note that cell A2 contains an actual date and A2:A15 are custom formatted ddd
    Let us know if you have any questions.
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    02-23-2020
    Location
    HK
    MS-Off Ver
    2019
    Posts
    25

    Re: Complex timesheet template!

    Thank you for looking into this again but seems like there are still some issues if bot tasks A and B are performed on the same day with OTs:

    I've marked the errors in red in the excel, the regular hours are shown in negative values and OT hour is not correct as well.

    Previously the template works well so not sure what the underlying issue is...wondering if you can help advise?

    Thank you so much for helping this again!! Please feel free to let me know if anything, thank you!
    Attached Files Attached Files

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

    Re: Complex timesheet template!

    The following modified formula for H2:H15 corrects for the regular hour values for task A on Tues and Fri:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The corresponding formula in column J is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I am confused by the start time are put into task B for Wed and am thinking that may be a mistake. If so please give me the correct start time and expected values for J11:K11
    Let us know if you have any questions.

+ 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. Timesheet template
    By eeps24 in forum Excel General
    Replies: 4
    Last Post: 01-03-2017, 05:10 PM
  2. Timesheet template design
    By smallks in forum Excel General
    Replies: 5
    Last Post: 05-22-2016, 10:31 PM
  3. [SOLVED] Complex timesheet help
    By awilliams8323 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-19-2014, 03:22 AM
  4. complex timesheet
    By nick1802 in forum Excel General
    Replies: 0
    Last Post: 04-24-2014, 10:40 AM
  5. Replies: 4
    Last Post: 01-07-2014, 10:10 PM
  6. complex timesheet
    By dadadididoo in forum Excel General
    Replies: 15
    Last Post: 06-04-2009, 07:30 AM
  7. [SOLVED] Excel Timesheet template
    By Asphalt in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-24-2005, 07:05 PM

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