Date formatting in VBA Userform for Excel 2010

Ozroly

New Member
Joined
Feb 8, 2017
Messages
2
HI Everyone

i am trying to setup an Excel 2010 userform that takes a date in TextBox and uses it as delivery date, the wierd thing is that sometimes it converts the date from Australian format DD/MM/YYY to american date format MM/DD/YYY.

i have read a couple of people talking about how excel is american centric hence why it converts the date and i have been trying to setup a format script on the code to force the Australian date formatting as below.

' trying to format date DD/MM/YYYY not MM/DD/YYYY
If Not IsDate(Me.DeliveryDateField.Value) Then
MsgBox "Input must be a date in the format: 'dd/mm/yyyy'", vbExclamation, "Essential Items"
Me.DeliveryDateField.SetFocus
DeliveryDateField = Format(DeliveryDateField, "dd/mm/yyyy")
Exit Sub


the debug doesnt pickup any errors so im not sure if something is overriding the date after this or if i am simply putting the date formatting command in the wrong place.

i REALLY hope someone can help me with this as its very tedious for me to have to get the data from the spreadsheet and then go into every invoice and check the date is in the correct format..
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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