+ Reply to Thread
Results 1 to 23 of 23

Very complicated calculation of total hours worked (PLEASE HELP)

  1. #1
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Very complicated calculation of total hours worked (PLEASE HELP)

    Hi. I have a spreadsheet that shows the amount of time that somebody worked over the course of several years. The spreadsheet is about 30,000 rows long and very poorly organized (more on this below). I need to calculate the hours worked by this individual each day over the course of all the years shown on the spreadsheet, but there are NOT separate columns for time clocked in and time clocked out. If there were separate columns for those values, I could calculate the total hours worked on the first day/row, and then I could drag the formula down the entire spreadsheet.

    Unfortunately, as I said, there are not separate columns for the clock-in and clock-out times. Instead there is one column for both times. To make matters worse, the column that shows times does not only show time clocked in and time clocked out; it also shows the times at which various work tasks were performed throughout the day (between the clock-in and clock-out times).

    Anyway, my boss wants me to figure out the total number of work hours recorded on the spreadsheet, and I have no idea how to proceed. The column that shows times (clocked in, clocked out, etc.) is right next to a column that shows the date (which is entered as a number rather than a date). Also, the date is written in the format YYYYMMDD, just to make things more confusing. So this is what the spreadsheet looks like:

    DATE | TIME | ACTIVITY
    20080507 | 9:30 | clock-in/work task #1
    20080507 | 11:30 | work task #2
    20080507 | 2:30 | work task #3
    20080507 | 4:30 | clock-out
    20080508 | 9:30 | clock-in/work task #1
    20080508 | 11:30 | work task #2
    20080508 | 2:30 | work task #3
    20080508 | 4:30 | clock-out
    20080509 | 9:30 | clock-in/work task #1
    20080509 | 11:30 | work task #2
    20080509 | 2:30 | work task #3
    20080509 | 4:30 | clock-out

    (NOTE: The actual spreadsheet contains extreme variation between the days in terms of the hours worked on each day.)

    Anyway, given the strange format of this spreadsheet, I have no idea how to automatically calculate the total hours worked down the entire spreadsheet. The only thing that I can do is create formulas for each day (one day at a time) and then add up all the hours once I've calculated them day-by-day. The process would take months, which is too long for the demands of my boss. By the way, I have to do this for 7 other spreadsheets that are also about 30,000 rows long.

    Is there any way to create formulas that can 1) divide the rows into segments based on the DATE values 2) automatically calculate the total time elapsed within each segment/day (using the first and last time values for each segment/day, which would represent, respectively, time clocked-in and time clocked-out)?

    As you can see, this problem far exceeds my Excel capabilities. I truly appreciate any and all help that you guys can offer. Thank you.

  2. #2
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    See the attached (VBA macro).

    Please Login or Register  to view this content.
    To use, copy your data into column A of Sheet "Input" in this file and click run button. The data is divided using "Text_to_Columns" and the paired time obtained.

    Output is Date/ Clock-In, Clock-Out . Dates are present twice just as a check. The assumption is there is always a pair of matching dates/times.

    NOTE: Clock out times appear to be of form 4:30 which I assume to be 16:30 so I add 12 hours to the time.

    Your sample data is in the file: just click RUN.
    Attached Files Attached Files
    Last edited by JohnTopley; 05-08-2016 at 08:17 AM.

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

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    Cross-posted at:
    http://www.msofficeforums.com/excel/...ed-please.html
    http://www.excelguru.ca/forums/showt...-(PLEASE-HELP)
    http://www.mrexcel.com/forum/excel-q...ease-help.html

    Please read the Cross-Posting policy in rule #8: http://www.excelforum.com/forum-rule...rum-rules.html

  4. #4
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    I'm very sorry for violating the cross-posting policy. It wasn't unintentional and won't happen again.

    John, thank you so much. I'll try out your solution.

  5. #5
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Hi, John. I just had the chance to take a closer look at the program you created. I'm a little confused. How can I paste all of my data into column A, given that there are multiple columns in play here (specifically, the date and time columns)?

    Also, I'm sorry. The third column (ACTIVITY) doesn't actually contain the terms "clock-in" and "clock-out." I should have made that clear above. The stuff entered in that column is totally inconsistent; it doesn't contain anything that can be used to help filter the cells. Is there another way to automate the overall calculation?

    Again, thank you so much for your time and generosity.

  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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    A senior moment on my part re the one column : working with 3 (or more) columns is fine.

    However unless it is possible to identify the "Clock in"/"clock out" times we cannot filter: is the first entry for a date the clock-in time (and likewise the last entry the clock out time)?

    Please post a file with a good sample of the data.

    To upload file: click "Go advanced" then "Manage Attachments".

  7. #7
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Yes, we can assume that the first time for each date is the clock-in time and the last time is the clock-out time.

    Given the large size of the spreadsheet, I have attached the first half (rows 1-15,000). I removed the activity column, as it seems useless and it's technically sensitive information.

    Thank you.
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Please Login or Register  to view this content.

    See attached

    I left both date columns in as a check.
    Attached Files Attached Files

  9. #9
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Quote Originally Posted by PrestonT View Post
    I'm very sorry for violating the cross-posting policy. It wasn't unintentional and won't happen again.
    Now also cross-posted at:
    http://forum.chandoo.org/threads/cal...-worked.29350/
    http://www.ozgrid.com/forum/showthread.php?t=199722
    http://www.vbaexpress.com/forum/show...-(PLEASE-HELP)

    So much for being sorry about Rules violations...
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

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

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    @JohnTopley

    I'm afraid you're losing your time on this one

  11. #11
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    @Pepe ...... you could be right! I'll await OP's response if any.

  12. #12
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Hi. John, I'm trying out your solution. Apologies for the delayed response. I really appreciate your time and generosity. Thank you.

    Also, I'm sorry for not adding the additional links. I'll do so from now on if there's ever any need, but I'll try to avoid cross-posting altogether.

  13. #13
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    John,

    This is super. Thank you.

    I have to concede that I posted this question in too many forums, and that was discourteous.

  14. #14
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    If your problem has been resolved, could you please mark the thread as solved ("Thread Tools" at top of first post).

    FYI: I did check some of the other forums and noted that you had (VBA) responses to your initial posting, illustrating why cross-posting should not been done as it can (does) result in wasted time and effort.

    While I have no experience of other forums, my experience of this one is that you will get very quick responses to any query: so hopefully lesson learned.

  15. #15
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    I marked the thread as solved.

    Yes, part of the reason that I cross-posted so excessively was that I didn't realize how eager people were to actually help. I assumed it would be more like, post on 5-10 message boards and be lucky if one of them yields a full solution. So, indeed, lesson learned.

    Thanks again, boss.

  16. #16
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Hi John,

    I actually had a follow-up question. I PM'd you, but the message didn't appear in my "Sent" folder, so I replicated it below to be on the safe side.

    How can I add more rows of data (in columns A and B) in such a way that the additional total hours calculations (shown in column J) are made correctly?

    I just tried to add more rows of data to columns A and B. Then, I dragged down columns F through J one column at a time (by double-clicking on the black crosses). It seems that I botched the formulas in the process. This is what happened:

    -The dates in F and H automatically increase by 1 after row 657. Thus, weekend dates that weren't included in the original data now appear.
    -The hours in columns G and I always increase increase by 1 after row 657.
    -As a result, column J remains static after row 657, repeatedly showing a value of 6:17.

    Any help is greatly appreciated.

    Separate question: Is there a way for me to delete all of the data that I have in A and B, insert new data, and get the correct calculations in column J? The reason that I ask is that I have to do this again for 7 additional spreadsheets full of data.

    Sorry to bother you again. Thanks so much for your time.

    Best,
    Preston

  17. #17
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    As per your PM: see attached file.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Thank you kindly

  19. #19
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    If your problem has been addressed, can you please mark thread as solved.

  20. #20
    Registered User
    Join Date
    05-08-2016
    Location
    LA
    MS-Off Ver
    the latest
    Posts
    15

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    Done. Thanks.

  21. #21
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    See attached:
    Attached Files Attached Files

  22. #22
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    See attached: clears 100000 rows and added code to calculate time rather than use formula.

    Please Login or Register  to view this content.

  23. #23
    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,147

    Re: Very complicated calculation of total hours worked (PLEASE HELP)

    See Attached: I had problems adding to previous note.
    Attached Files Attached Files

+ 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. Calculation Hours worked
    By NeedExcelHelp82 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-11-2014, 08:42 PM
  2. Replies: 6
    Last Post: 01-23-2012, 01:28 AM
  3. Number of hours worked calculation
    By kosciosco in forum Excel General
    Replies: 1
    Last Post: 06-03-2010, 11:52 AM
  4. Replies: 6
    Last Post: 05-03-2010, 12:03 PM
  5. Hours Calculation worked.
    By coolhit in forum Excel General
    Replies: 1
    Last Post: 12-01-2009, 08:06 AM
  6. Hours worked calculation
    By drathnal in forum Excel General
    Replies: 7
    Last Post: 12-03-2008, 01:06 PM
  7. total of hours worked
    By carolynkeene in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2006, 03:29 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