+ Reply to Thread
Results 1 to 11 of 11

Format to display in excess of 24 hours

  1. #1
    Registered User
    Join Date
    07-19-2010
    Location
    Yorkshire
    MS-Off Ver
    Excel 2007
    Posts
    8

    Format to display in excess of 24 hours

    I have a time sheet in which I need to show a daily running total of hours worked.

    The attached sheet is formatted in such a way that times can be entered in military time, i.e. just four numbers without the colon. The colon is added automatically by the format of those cells. The time calculations all appear to work as far as adding up daily hours etc. The problem appear in column J which should show the total weekly hours worked as every days times are added to the sheet. All works well until the total hours exceed 24. After that all sorts of weird figures appear. The green highlighted column shows the expected results.

    I've tried all sorts of different formats for column J but once the total exceeds 24 it all falls apart.

    Can anyone point me in the right direction please?

    Thanks,
    Lee
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Format to display in excess of 24 hours

    Your values for time do not have the semi colon between and are written as 800 1200 etc.

    I'll amend on your template a formula to factor this in but if you change those to time values you can simply use

    =SUM(D2-C2)+SUM(G2-F2) in I2 and drag down
    Last edited by PFDave; 12-14-2016 at 10:40 AM.

  3. #3
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Format to display in excess of 24 hours

    Clean data in = clean data out
    Attached Files Attached Files

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Format to display in excess of 24 hours

    Hi,

    If you format column I as [h]:mm you will see where the results in J come from. It is unclear to me what you think that these two parts in the I2 formula are for
    +(D2>-C2)
    +(G2>-F2)

    but all they achieve is to add two days to the result.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Registered User
    Join Date
    07-19-2010
    Location
    Yorkshire
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Format to display in excess of 24 hours

    Hi PFDave,

    Thanks for your help.

    The reason that times are shown 800, 1200 etc. are as I said in my post... so that users can simply enter 4 digits for the time and not have to mess about entering a colon. Those cells are custom formatted as "00\:00" which displays the time as if it had been entered with a colon.
    I realise it would be far simpler if users would enter times in the correct format, but they dont! Hence the formulas to convert the entries into "proper" times before doing the calculations; that all works.

    Column I does work and seems to handle all the calculations correctly. It's only the addition of all the hours in column J where things fall over. That's the part I can't figure out.

  6. #6
    Registered User
    Join Date
    07-19-2010
    Location
    Yorkshire
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Format to display in excess of 24 hours

    Quote Originally Posted by xlnitwit View Post
    Hi,

    If you format column I as [h]:mm you will see where the results in J come from. It is unclear to me what you think that these two parts in the I2 formula are for
    +(D2>-C2)
    +(G2>-F2)

    but all they achieve is to add two days to the result.
    The reason for those bits is to handle the calculations correctly where a start time falls before midnight and the end time falls after midnight. If those bits are omitted the calculation doesn't work.

  7. #7
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Format to display in excess of 24 hours

    Sorry but without a valid time format I can't make this work for you.

    The entry for 8:00 as 800 can be converted to the right value using SUM(800/100/24), however as there are entries for 7:30 as 730 (as hundreds should be 750) this will not calculate.

    If the users really have an issue entering clean data I would personally force each input with a userform to ensure it is entered correctly.

    Sorry again I can't be of any use

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Format to display in excess of 24 hours

    The calculation doesn't work anyway since D2 will always be greater than negative C2.

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Format to display in excess of 24 hours

    Quote Originally Posted by Snaggles View Post
    Column I does work and seems to handle all the calculations correctly. It's only the addition of all the hours in column J where things fall over. That's the part I can't figure out.
    As I mentioned above, column I does not in fact work. Format the cells as [h]:mm and you will see that 48 hours has been added to each cell.

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Format to display in excess of 24 hours

    I think that this version may work for you.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-19-2010
    Location
    Yorkshire
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Format to display in excess of 24 hours

    Just come back to this little puzzle and have seen your last post and attached sheet... thanks.

    Had solved the problem myself with a little lateral thinking... along similar lines though.
    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. Correct format to display business hours/days
    By M.e.R. in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-28-2015, 10:09 AM
  2. Replies: 3
    Last Post: 09-05-2015, 09:18 AM
  3. [SOLVED] TextBox - Display hours greater than 24 and negative hours too.
    By gnaske in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-21-2014, 03:01 PM
  4. Replies: 4
    Last Post: 09-03-2013, 02:52 AM
  5. Replies: 3
    Last Post: 12-21-2012, 05:35 AM
  6. [SOLVED] Format a cell to display decimal hours.
    By Fred Holmes in forum Excel General
    Replies: 2
    Last Post: 03-18-2005, 12:06 PM
  7. ADD TIME IN EXCESS OF 24 HOURS
    By Elizabeth in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-18-2005, 05: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