Excel - Date entry using userform

  oo7juk 15:08 06 Mar 2009

I'm trying to enter the following date 05/04/08 via a userform, but when I enter date it appears on the spreadsheet as 04/05/2008.

Here is my code

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("VolumeAnalysis")

iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

If Trim(Me.txtcallv.Value) = "" Then
MsgBox "Please enter call data"
Exit Sub
End If

ws.Cells(iRow, 1).Value = Me.txtcallv.Value
ws.Cells(iRow, 2).Value = Me.txtcallv2.Value
ws.Cells(iRow, 3).Value = Me.txtcallv3.Value

Me.txtcallv.Value = ""
Me.txtcallv2.Value = ""
Me.txtcallv3.Value = ""

End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Many thanks,

  MAJ 15:33 06 Mar 2009

Silly question I'm afraid, but you have made sure the date cell is formatted as Date > Locale(Location:) section > English (United Kingdom), oo7juk?

  oo7juk 15:41 06 Mar 2009

MAJ - explored that option, no luck though.

  VoG II 16:25 06 Mar 2009


ws.Cells(iRow, 1).Value = CDate(Me.txtcallv.Value)

  oo7juk 16:45 06 Mar 2009

Thanks that worked a treat, what does the CDate stand for?

Many thanks.

  VoG II 16:49 06 Mar 2009

CDate converts something that looks like a date into a date.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Xiaomi Mi Mix 2 review

See mcbess's iconic style animated for Mercedes-Benz

iPhone X news: Release date, price, new features & specs

Black Friday 2017 : date, sites participants & bonnes affaires