Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms data entry - MM/DD/YYYY
I have a custom user form that pops up during one of the macros I run. In one
text box the user has to enter a date. I would like to write some code so that the user can only enter the date in the MM/DD/YYYY format - eg. 11/07/2004. What is the VBA code for this? Any help would by appreciated. Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms data entry - MM/DD/YYYY
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim cDelim As Long cDelim = Len(TextBox1.Text) - Len(Replace(TextBox1.Text, "/", "")) Select Case KeyAscii Case Asc("0") To Asc("9"): 'OK Case Asc("/"): If cDelim = 2 Then KeyAscii = 0 Else cDelim = cDelim + 1 End If Case Else: KeyAscii = 0 End Select End Sub This can be amended to be more specific -- HTH RP (remove nothere from the email address if mailing direct) "UmpaL00mpa" wrote in message ... I have a custom user form that pops up during one of the macros I run. In one text box the user has to enter a date. I would like to write some code so that the user can only enter the date in the MM/DD/YYYY format - eg. 11/07/2004. What is the VBA code for this? Any help would by appreciated. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data Entry with forms | Excel Worksheet Functions | |||
complex data entry forms design with excel | Excel Discussion (Misc queries) | |||
Excel Data Entry Forms (Data, Worksheet) | Excel Discussion (Misc queries) | |||
Forms - Error Message for Non-Entry of Data | Excel Discussion (Misc queries) | |||
Help With Restricting Values in Data Entry Forms please | Excel Programming |