+ Reply to Thread
Results 1 to 4 of 4

Using VB to address hours worked past midnight

  1. #1
    Forum Contributor
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    102

    Using VB to address hours worked past midnight

    Another off-beaten topic, but most of my googling using VB tag leads to excel formulas, and I can't figure out how to convert to VB.

    Anyway, very simple. I need to calculate hours worked. Some ending shifts will cross midnight. No shift will start between midnight and 5am.

    Also, I am using the following code, but I have no idea how it works (specifically, the worksheetfunction.sum). It just does. The times that the code is looking at are stored as text values. An example formula is "=IF($L8="","",TEXT($I8,"H:MM AM/PM"))"

    Please Login or Register  to view this content.
    The First If says that if the shift start time is less than the employee's availability start time, then there is an availability conflict
    The Second If says that if the shift end time is after the employee's availability end time, then there is an availability conflict
    That works great if the end time is not midnight or later.
    The next If statement needs to address the issue if the scheduled end time is after midnight.

    The remarked lines are ones I have been experimenting with but do not work

    ALSO, I need to also address how to calculate hours worked when a shift crosses over midnight.

    Sample Attached

    Sample Schedule.xlsx

    Thanks in advance.
    Last edited by ZooTV92; 05-02-2012 at 09:25 AM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using VB to address hours worked past midnight

    Named Range cannot be found in that workbook (the L8 dropdown).

  3. #3
    Forum Contributor
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Using VB to address hours worked past midnight

    I took them out because of sensitive info

    Also, I double remarked a line in the code I entered in the OP.....it is not working code...another failed experiment.
    Last edited by ZooTV92; 05-02-2012 at 09:24 AM.

  4. #4
    Forum Contributor
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Using VB to address hours worked past midnight

    /bump

    Can anyone assist with this? Really stumped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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