Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don't do this please. Don't prompt "Invalid date entry" on an annoying modal
msgbox just because the user entered a four digit year or forgot a leading zero, your users will hate the application with good reasons. There are several valid date formats and you should accept as many as possible. Do Dt = Datevalue(Me.Textbox1.Text) and it accepts June 1, 12/31/08 and multiple others that makes sense in the user's country. Your validation should be if the date is later than someday reasonable or if Datevalue errs. HTH. Best wishes Harald "nir020" wrote in message ... I am creating a userform in excel, I need to create a user inputs into a which a valid date can only be entered. The required Date Format is "dd/mm/yy". Can someone show me how to do this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I fully agree with what Harald said. To add to it, though, you can always
use the Format function after you have validated the entry is, in fact, a date (use the IsDate function for that) to put the date into whatever format you need. So, code along these lines... Dt = Me.TextBox1.Text If IsDate(Dt) Then DateInDesiredFormat = Format(Dt, "dd/mm/yy") Else MsgBox Your entry (" & Dt & ") is not a valid date!" End If -- Rick (MVP - Excel) "Harald Staff" wrote in message ... Don't do this please. Don't prompt "Invalid date entry" on an annoying modal msgbox just because the user entered a four digit year or forgot a leading zero, your users will hate the application with good reasons. There are several valid date formats and you should accept as many as possible. Do Dt = Datevalue(Me.Textbox1.Text) and it accepts June 1, 12/31/08 and multiple others that makes sense in the user's country. Your validation should be if the date is later than someday reasonable or if Datevalue errs. HTH. Best wishes Harald "nir020" wrote in message ... I am creating a userform in excel, I need to create a user inputs into a which a valid date can only be entered. The required Date Format is "dd/mm/yy". Can someone show me how to do this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Date and Time Formats in UserForms | Excel Programming | |||
UserForms | Excel Discussion (Misc queries) | |||
Userforms | Excel Programming | |||
Problems with date format in userforms | Excel Programming | |||
Userforms | Excel Programming |