Userform Date

  • Thread starter Thread starter Paul Brown
  • Start date Start 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.
 
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
 
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
 
Back
Top