Dates? Please Help

MrGJEB

New Member
Joined
Jun 13, 2008
Messages
37
I am using the following code to validate the text being entered into a text box in my userform.

Private Sub TXTdatefirstlayout_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If IsDate(TXTdatefirstlayout.Value) Then
TXTdatefirstlayout.Value = Format(TXTdatefirstlayout.Value, "dd/mmm/yyyy")

Else

MsgBox "Please enter a date. DD/MM/YYYY"
Cancel = False

End If
End Sub

The validation works however when the user clicks on save the date is shown in in the corresponding cell on my worksheet is in USA format (MM/DD/YYYY) not UK format (DD/MM/YYYY). I have checked the cell format on my worksheet and is is set to the UK format.

I am thinking is it anything to do with the "IsDate" part of the above formula.

Any help would be much appreciated.

Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
When you write the value to the worksheet, use CDate:
Code:
Range("A1").value = CDate(TXTdatefirstlayout.Value )
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,520
Members
449,088
Latest member
RandomExceller01

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