+ Reply to Thread
Results 1 to 5 of 5

Time difference caliculation on a userform

  1. #1
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Time difference caliculation on a userform

    HI all, am struggling to workout how to show the difference between a start time in textbox9 and an end time in textbox11 on a userform, users will enter the times hour and mins in these boxes and on exiting textbox11, I would like the result to show in textbox12

    any code to help would be useful

    scouse13

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Time difference caliculation on a userform

    Hi scouse13,

    I don't know what you are doing to validate/restrict the values in the textboxes, but if it is guaranteed to be a time, and is in 24hr format, then this might work for you:

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: Time difference caliculation on a userform

    Quote Originally Posted by Arkadi View Post
    Hi scouse13,

    I don't know what you are doing to validate/restrict the values in the textboxes, but if it is guaranteed to be a time, and is in 24hr format, then this might work for you:

    Please Login or Register  to view this content.
    Thanks Arkadi, that works fine, but it does not work correctly if the time exceeds 24 hours, could I insert 2 more boxes for date entry and could the code be changed to take this into account

    scouse13

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Time difference caliculation on a userform

    My apologies for the late reply, yes that can definitely be done. In my example:

    Textbox9 has the "start time" meaning the earlier time
    Textbox14 has the "start date" which is lower or equal to the end date (at least I only tested in that direction)
    Textbox 11 has the "end time"
    Textbox13 has the "end date"
    Textbox12 will display the result

    Please Login or Register  to view this content.
    You'd want the same code in _AfterUpdate for Textbox11, 13 and 14
    Last edited by Arkadi; 02-21-2020 at 03:08 PM.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Time difference caliculation on a userform

    Thanks for the rep, and marking the thread as solved

+ 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. Replies: 1
    Last Post: 10-18-2019, 12:38 AM
  2. Replies: 3
    Last Post: 08-12-2017, 01:48 AM
  3. Userform compute for time difference in text box
    By aarona in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2017, 01:20 PM
  4. [SOLVED] Difference between initial time and final time code not working correcly!
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-07-2017, 06:28 AM
  5. [SOLVED] Time in Time format and text foramt - Finding the Hours difference
    By thilag in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2013, 07:14 AM
  6. VBA userform Time difference in text box
    By Hilton1982 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-23-2012, 04:56 AM
  7. [SOLVED] Caculating the Time difference from Start & end date/time excludin weekends & non ofce hrs
    By Harry Jones in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-08-2012, 06:25 AM

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