+ Reply to Thread
Results 1 to 16 of 16

VBA Userform "CDate" calculations on Times = Total Hrs

  1. #1
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    VBA Userform "CDate" calculations on Times = Total Hrs

    Hi Guys,
    I have a formula in my UserForm that give me h:mm, but the problem is I have staff that start at e.g. 09:00am and finishes at 02:00am, this formula I have give me return 7:00 hrs, when the return should be 17:00hrs. Does anyone know how to fix this?

    HTML Code: 
    Cross posted at https://www.mrexcel.com/board/thread...l-hrs.1150373/ --6SJ
    Last edited by 6StringJazzer; 11-05-2020 at 06:44 PM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Hi,
    When the time spans the midnight hout, you will have to do two calculations:

    one from 23:59:59 - 09:00:00 and add the value from 00:00:00 + 02:00:00
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Thanks Keebellah,
    I'm not that good with VBA, How would I code this?

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    I will need to see how you've filled the values in the textboxes.
    And when you show a vba example you expect others to assume that you do know something
    I'll put it together and update

  5. #5
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    My Apologise,
    Doe this help?

    Please Login or Register  to view this content.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,809

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided. If you do not have permission to post the link, PM me.)

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Try this, paste this code in your Userform module

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Hi, Sorry was typing my answer and didn't see your posting about the cross-posting. until after

  9. #9
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Hi 6StringJazzer,
    I'm sorry, I wasn't aware I was allowed to do this, I'm only new at this. I would share the link but it's won't let me. You ask to PM you, what does PM mean?

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,809

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Quote Originally Posted by Kitsa View Post
    I'm sorry, I wasn't aware I was allowed to do this, I'm only new at this. I would share the link but it's won't let me. You ask to PM you, what does PM mean?
    I edited your first post to add the link for you.

    PM means Private Message. To PM someone click on their name and then select Private Message from the pop-up window.

    When you join any online forum, the first thing you should do is get familiar with their rules. Please take two minutes to review our rules. There aren't many, and they are all important.

  11. #11
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Thanks and apologise again.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Just in case the code did not come throufg:

    Please Login or Register  to view this content.
    Attached Images Attached Images

  13. #13
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Hi Keebellah,
    It came through and worked for me, but I would like it to come up 24:00 if I put start date 09:00AM to 09:00AM, at the moment it comes up 00:00. How can I do that?

  14. #14
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    Thank you everyone for helping. This is now solved. How do I mark this thread as solved?

  15. #15
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,809

    Re: VBA Userform "CDate" calculations on Times = Total Hrs

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937
    Quote Originally Posted by Kitsa View Post
    Hi Keebellah,
    It came through and worked for me, but I would like it to come up 24:00 if I put start date 09:00AM to 09:00AM, at the moment it comes up 00:00. How can I do that?
    Did you see my last post/answer?

+ 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. Coding Help - CDate & "Greater Than" Date
    By imacna11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-04-2015, 04:01 PM
  2. Short "Basic" Macro to copy and paste formulas "N" times.
    By gradyhawks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-09-2014, 02:34 PM
  3. [SOLVED] find a total of times a word appears across all the sheets in column "C"
    By NickB79 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 10:28 AM
  4. Separate cell which have "Comma" into different row & multiple each row "n" times
    By Arun ebl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-09-2013, 11:22 PM
  5. "Fun times in no mans land" Translation - "Selective Duplication"
    By amonty87 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-09-2013, 03:21 AM
  6. [SOLVED] Macro to delete entire row if cell contains the word "total" or "Total"
    By theatricalveggie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2011, 12:38 PM
  7. [SOLVED] Linking two "total" pages to create a "Complete Total" page
    By Jordon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-10-2006, 07:20 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