![]() |
Date textboxe in userforms
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? |
Date textboxe in userforms
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? |
All times are GMT +1. The time now is 05:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com