+ Reply to Thread
Results 1 to 3 of 3

Userform TextBoxes - Compare Time Values

  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    118

    Userform TextBoxes - Compare Time Values

    In my userform, I have two textboxes that are formatted to "HH:MM AM/PM" on a 12 hours clock after the user enters time in military time (24 hour clock). But now I'm trying to make sure the 2nd textbox isnt earlier than the 1st textbox. I've been tinkering around with the Exit event and simply comparing their .values in an if statement, but I dont think its working properly. I intuitively feel like I need to have some sort of format call to properly compare the values. The code is below. The commented out portion is whats giving me trouble. I know it looks like a 5 year old coded this; Im just a mechanical engineer, not a computer scientist. Thanks for any input!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,021

    Re: Userform TextBoxes - Compare Time Values

    The values in the textboxes are text, if you want to compare them as times you'll need to convert them to time values.

    You can do that using the TimeValue conversion function, which you are already using in the code you posted.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    118

    Re: Userform TextBoxes - Compare Time Values

    Thank you!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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