+ Reply to Thread
Results 1 to 10 of 10

Help with calculating time

  1. #1
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Help with calculating time

    So I made a basic template of a schedule I need for work. But I'm trying to clean it up a little and shorten up the cells. I've attached a template using Excel 2010. What I need to do is figure out how to a set up time as "8am - 5pm" in one cell versus using two cells to calculate the hours worked. For example, if you look at the template you will see that I have a start time on cell B4 and an end time on cell C4. I want to get rid of both cells and just keep, lets say, B4 with a time range of "8am - 5pm" but I need Excel to recognize as 8am through 5pm so that I can figure out how many hours were worked. Once that's solved I would also appreciate if anyone can help me so that whenever I put an "X" in the cell it will calculate the hours worked as "0" (zero). Thanks
    Attached Files Attached Files
    Last edited by marios80; 11-09-2013 at 03:48 AM. Reason: Solved

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Help with calculating time

    Welcome to the Forum marios80!

    Quote Originally Posted by marios80 View Post
    I want to get rid of both cells and just keep, lets say, B4 with a time range of "8am - 5pm" but I need Excel to recognize as 8am through 5pm
    It is possible to do this, but that's a very undesirable design. Using two times requires a simple subtraction, but using a string that like requires a complicated formula to break down the string and parse each piece. Also it is more likely that the user will make an unnoticed data entry error, and writing the formula to detect such errors is even more complicated. Using two separate cells for start and end times is the standard solution to this--why do you need it in one cell?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Help with calculating time

    Quote Originally Posted by 6StringJazzer View Post
    Welcome to the Forum marios80!

    It is possible to do this, but that's a very undesirable design. Using two times requires a simple subtraction, but using a string that like requires a complicated formula to break down the string and parse each piece. Also it is more likely that the user will make an unnoticed data entry error, and writing the formula to detect such errors is even more complicated. Using two separate cells for start and end times is the standard solution to this--why do you need it in one cell?
    The person I did this for is real picky. Its my GIRLFRIEND LOL!!! I'm trying to clean it up for her and display it the way she wants it. I understand that the data entry will need to be real specific otherwise it would cause an error but if you could help me with the formula I would really appreciate your help.

  4. #4
    Forum Contributor amit.wilson's Avatar
    Join Date
    07-09-2013
    Location
    Gotham
    MS-Off Ver
    Excel for Mac 2011
    Posts
    283

    Re: Help with calculating time

    Hi - try this:

    Cell A1 : 8:00 am - 5:00 pm
    Cell B1 : =(TIMEVALUE(MID(A1,(FIND("-",A1))+1,((LEN(A1))-(FIND("-",A1))))))-(TIMEVALUE(LEFT(A1,(FIND("-",A1))-1)))

    You'll need to make sure there is a gap between "8:00" and "am" and similarly between "5:00" and "pm" or the formula won't work.

    This also takes care of your second question ("put an "X" in the cell it will calculate the hours worked as "0" (zero).")

    Cheers
    AW

  5. #5
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    503

    Re: Help with calculating time


  6. #6
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Help with calculating time

    Quote Originally Posted by amit.wilson View Post
    Hi - try this:

    Cell A1 : 8:00 am - 5:00 pm
    Cell B1 : =(TIMEVALUE(MID(A1,(FIND("-",A1))+1,((LEN(A1))-(FIND("-",A1))))))-(TIMEVALUE(LEFT(A1,(FIND("-",A1))-1)))

    You'll need to make sure there is a gap between "8:00" and "am" and similarly between "5:00" and "pm" or the formula won't work.

    This also takes care of your second question ("put an "X" in the cell it will calculate the hours worked as "0" (zero).")

    Cheers
    AW
    Thank you for the formula! It works fine except for the "X" part. When I put "X" in the cell it gives me "#value!"

    Anyway you can possibly fix that?

  7. #7
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Help with calculating time

    Quote Originally Posted by Toonies View Post
    That's also a good template but not quite what I was looking for but thanks for the help.

  8. #8
    Forum Contributor amit.wilson's Avatar
    Join Date
    07-09-2013
    Location
    Gotham
    MS-Off Ver
    Excel for Mac 2011
    Posts
    283

    Re: Help with calculating time

    Sorry - here is the correct formula:

    Cell A1 : 8:00 am - 5:00 pm
    Cell B1 : =IF(A1="x",0,(TIMEVALUE(MID(A1,(FIND("-",A1))+1,((LEN(A1))-(FIND("-",A1))))))-(TIMEVALUE(LEFT(A1,(FIND("-",A1))-1))))

    You could also try this alternative:

    Cell A1 : 8:00 am - 5:00 pm
    Cell B1 : =IFERROR((TIMEVALUE(MID(A1,(FIND("-",A1))+1,((LEN(A1))-(FIND("-",A1))))))-(TIMEVALUE(LEFT(A1,(FIND("-",A1))-1))),0)

    With the first alternative, you'll get '#Value' if you type in anything other than the time of X. With the 2nd alternative, you won;t get '#Value!'.

    Cheers

  9. #9
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Help with calculating time

    Ok, I actually figured it out with the template that "Toonies" referred to. Here's the correct template that I needed. Thanks to everyone for their help!
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Help with calculating time

    wow! I saved the wrong document. Oh well. I have to update it again tomorrow and then re upload the correct one.

  11. #11
    Registered User
    Join Date
    11-07-2013
    Location
    Behind the computer
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Help with calculating time

    Here is the corrected template if anyone is interested. Thanks!
    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. Calculating staff roster time to hours, depending on time worked.
    By cookiet in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-16-2013, 10:25 AM
  2. Replies: 3
    Last Post: 11-21-2012, 05:47 AM
  3. Formula for Calculating Paid Time Off for fiscal anniversary date real time
    By 168rockwood in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-07-2012, 04:15 PM
  4. Calculating END time based on start time, breaks, and hours to complete
    By sweedey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2012, 11:29 AM
  5. Excel Formulas for Calculating Straight, Over Time & Double Time in Cost Estimating
    By redhairredhair in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2010, 09:06 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