Hi all,
Anyone know how I can limit TextBox2 to only accept this format HH:MM (i.e HH: numbers 1-23 and MM: numbers 00-59). If this is not entered correctly a Message Box pops upk saying as such.
Thanks
Hi all,
Anyone know how I can limit TextBox2 to only accept this format HH:MM (i.e HH: numbers 1-23 and MM: numbers 00-59). If this is not entered correctly a Message Box pops upk saying as such.
Thanks
Hello Plumby,
Add this macro to your UserForm.
![]()
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) With TextBox2 If .Value = "" Then Exit Sub On Error Resume Next If .Value <> Format(TimeValue(.Value), "hh:mm") Then MsgBox "Entry '" & .Value & "' is not in HH:MM format." On Error GoTo 0 .Value = "" Cancel = True End If End With End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks