LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Userform Date Formatting MM/DD/YYYY

Thank you in advance for your help.

I have a UserForm with the following code:

ActiveCell.Offset(0, 1).Select
Selection.NumberFormat = "MM/DD/YYYY"
ActiveCell = UserForm1.TextBox2

The user is entering a date into Textbox2. I want to make
it so that they can only enter the date in MM/DD/YYYY
format. The above code doesn't realy work.

So far I have tried the following:

1. I went into Control Panel - Regional Options and set
the short date format as MM/DD/YYYY. This updates the
dates when I type them directly into Excel but not when I
enter dates in the UserForm and then have the UserForm
place the dates on the worksheet.

2. I also tried the following code from another Newsgroup:
Private Sub TextBox2_KeyPress(ByVal KeyAscii As _
MSForms.ReturnInteger)
Dim cDelim As Long
cDelim = Len(TextBox2.Text) - Len(Replace
(TextBox2.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 hasn't solved my problem either. Maybe I'm not
placing this code in the correct part of the Userform? I
am using Windows 2000 Professional and Excel 2000. Thanks
again for your help.
 
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
change date format from dd/mm/yyyy to mm/yyyy flow23 Excel Discussion (Misc queries) 3 April 4th 23 11:26 AM
Help with date format mm/dd/yyyy vs. dd/mm/yyyy Dream Excel Discussion (Misc queries) 3 September 10th 09 07:33 PM
want formula bar date to be dd/mm/yyyy instead of mm/dd/yyyy.How? magna Excel Discussion (Misc queries) 1 January 1st 08 04:23 AM
convert date mm/dd/yyyy to dd/mm/yyyy maryj Excel Worksheet Functions 2 March 20th 07 07:38 PM
how do I change date from mm/dd/yyyy to dd:mm:yyyy format in Excel Jack Wilson New Users to Excel 4 July 18th 06 01:57 PM


All times are GMT +1. The time now is 12:16 PM.

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

About Us

"It's about Microsoft Excel"