Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Entry with forms rookie Excel Worksheet Functions 1 September 4th 08 04:39 AM
complex data entry forms design with excel Amol Karnik Excel Discussion (Misc queries) 3 December 21st 07 12:19 PM
Excel Data Entry Forms (Data, Worksheet) No Name Excel Discussion (Misc queries) 1 June 28th 07 10:12 PM
Forms - Error Message for Non-Entry of Data morrisli Excel Discussion (Misc queries) 0 February 7th 07 09:36 AM
Help With Restricting Values in Data Entry Forms please Carnage Excel Programming 1 May 27th 04 11:41 AM


All times are GMT +1. The time now is 08:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"