Date format

carld

New Member
Joined
Aug 27, 2002
Messages
6
I got this code from somewhere to format the date to dd/mm/yy,

Private Sub txtCommence_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Private Sub txtCommence_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim a() As String
Dim b(2) As String
If Not IsDate('Private Sub txtCommence_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim a() As String
Dim b(2) As String
If Not IsDate(txt!!!.Value) Then
MsgBox "Enter valid Date: e.g. 01/01/02"
Exit Sub
End If
a = Split((CStr(CDate(txt!!!.Value.Value))), "/")
b(0) = a(0)
b(1) = a(1)
b(2) = a(2)
txt!!!.Value.Value = Join(b(), "/")
End Sub) Then
MsgBox "Enter valid Date: e.g. 01/01/02"
Exit Sub
End If
a = Split((CStrCDatetxt!!!.Value.Value))), "/")
b(0) = a(0)
b(1) = a(1)
b(2) = a(2)
txt!!!.Value.Value = Join(b(), "/")
End Sub

it doesn't work to well as the date keeps on changing back to mm/dd/yy. Does any body know how to make the date stay in the dd/mm/yy format.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
what data type are you trying to convert to a date?

the cdate() function will convert the following strings to "19/01/1972":

"01/19/1972"
"01/19/72"
"19 Jan 1972"
 
Upvote 0

Forum statistics

Threads
1,203,534
Messages
6,055,954
Members
444,839
Latest member
laurajames

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top