+ 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
    124

    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,643

    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
    124

    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)

Similar Threads

  1. Edit values in textboxes userform
    By travelkid in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-11-2019, 10:49 AM
  2. Edit values in textboxes userform
    By travelkid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2019, 12:34 PM
  3. [SOLVED] Pass values of UserForm TextBoxes to 2D Array
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2018, 05:20 AM
  4. [SOLVED] Userform Command Button to add more comboboxes and textboxes at the same time
    By charscribbles in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-29-2014, 12:35 PM
  5. Replies: 3
    Last Post: 11-05-2014, 01:11 PM
  6. Is there a way to format all TextBoxes on a UserForm the same at one time?
    By D3Pratt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2009, 09:09 AM
  7. Userform Textboxes showing wrong values?
    By Panic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2008, 09:43 PM

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