Userform Date

P

Paul Brown

Hi all,

I have a userform where a date is entered in a text box (e.g. 01/12/05). On
submit the date is entered into a cell which is formatted dd-mmm-yy
(01-Dec-05). The problem is that when the date is transferred into the cell
it reads 12-Jan-05. Is there any way within the code for the userform or
textbox to ensure that the date is transferred across UK style rather than
US style?

Apologies if that has been covered but I couldn't see it anywhere.

Thanks.

Paul.
 
H

Harald Staff

Hi Paul

Datevalue will consider the local settings on the computer. Try

Private Sub CommandButton1_Click()
Dim Dt As Date
If IsDate(TextBox1.Text) Then
Dt = DateValue(TextBox1.Text)
Sheets(1).Range("D2").Value = Dt
End If
End Sub

HTH. Best wishes Harald
 
P

Paul Brown

Harald,

Many thanks - works a treat.

Harald Staff said:
Hi Paul

Datevalue will consider the local settings on the computer. Try

Private Sub CommandButton1_Click()
Dim Dt As Date
If IsDate(TextBox1.Text) Then
Dt = DateValue(TextBox1.Text)
Sheets(1).Range("D2").Value = Dt
End If
End Sub

HTH. Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top