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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
When you write the value to the worksheet, use CDate:
Code:
Range("A1").value = CDate(TXTdatefirstlayout.Value )
 
Upvote 0

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

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