Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a date from a UserForm
I've recently built an Excel based application for some of our staff and have
now encountered a problem that I can't figure out. A userform prompts the user to enter a date.. they enter it in the UK format (08/03/05 for 8th March), but the data posts to the underlying worksheet as 03/08/05...and if we use dd-mmm-yy (on the sheet) it converts to 03-aug-05. I obviously need to somehow define the format of the variable "xdate" I can get round it by forcing it to accept the date as text, but this then limits it's use. I'd really appreciate your suggestions... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a date from a UserForm
Hi
Use Datevalue and you will be safe. Dates will be interpreted in the local language and can be entered in any common way: Private Sub CommandButton1_Click() Dim D As Date If IsDate(TextBox1.Text) Then D = DateValue(TextBox1.Text) Sheets(1).Range("B4").Value = D Else TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) MsgBox "Invalid date entry" End If End Sub HTH. Best wishes Harald "Black1" skrev i melding ... I've recently built an Excel based application for some of our staff and have now encountered a problem that I can't figure out. A userform prompts the user to enter a date.. they enter it in the UK format (08/03/05 for 8th March), but the data posts to the underlying worksheet as 03/08/05...and if we use dd-mmm-yy (on the sheet) it converts to 03-aug-05. I obviously need to somehow define the format of the variable "xdate" I can get round it by forcing it to accept the date as text, but this then limits it's use. I'd really appreciate your suggestions... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a date from a UserForm
Harald...
Thanks, that's exactly what I needed. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Returning date instead of 'not null' | Excel Worksheet Functions | |||
Formula for returning date entered by date on another worksheet | Excel Worksheet Functions | |||
Date in userform being saved as general not date which affects sor | Excel Programming | |||
Userform to select start date and end date | Excel Programming | |||
Returning a date as a serial umber | Excel Programming |