Userform Date always reverts to American format

Henrybukowski

New Member
Joined
Apr 16, 2013
Messages
29
Dear all,
I have a problem with american date formats always reoccuring. I have seen other posts on this problem but none matching my particular issue.

I have a userform in which my users enter data which is then added to the excel spreadsheet.
Sometimes they need to amend this data so we have made their data editable - it gets put back into the userform so that changes can be made.

The issue is with dates. These are entered as dd/mm/yyyy but when they are then added to the userform they always go back to mm/dd/yyyy

The code to put the userfrom data to the spreadsheet is as follows:


<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">
Code:
ws.Cells(iRow, 28).Value = Me.refdate.Value </code>[/COLOR][COLOR=#333333][FONT=monospace]
[/FONT]

...Then to put it back into the form for editing:


Code:
[/FONT][/COLOR][COLOR=#333333]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">.refdate.Value = Cells(ActiveCell.Row, "AB").Value </code>[/COLOR][COLOR=#333333][FONT=monospace]
I made some progress by specifying instead of the first line:


Code:
[/FONT][/COLOR][COLOR=#333333]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">ws.Cells(iRow, 75).Value = DateValue(Me.phdat.Value)</code>[/COLOR][COLOR=#333333][FONT=monospace]

Using DataValue or CDate. This works to an extent because data is now added in the format dd/mm/yyyy - hooray!

However, when put back into the userform it still goes back in the form mm/dd/yyyy!!!!

Is there a way I can override this American date format which keeps coming back?

Many thanks in advance

Henry

NB: Linked:
http://www.excelforum.com/excel-programming-vba-macros/1149872-date-always-reverts-to-american-format-in-userform.html
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
What is refdate? A Textbox or something else?
 
Upvote 0
If it's just a textbox then it should show the cell contents as they are. If you are seeing the data with day/month swapped, that would suggest the date in the cell is actually swapped but perhaps formatted to display the way you expect.
 
Upvote 0
Rory, thanks for you reply but not sure I follow.
The cells are formatted to Date as well if that's what you mean?

If it helps when I tried working with 'DateValue' I now get a particular error which is Run-time Error 13: Type: Mismatch.

It then highlights yellow ' ws.Cells(iRow, 28).Value = DateValue(Me.refdate.Text) '
Hmmm
 
Upvote 0
That would imply that whatever is in the refdate control can't be converted to a date using your regional settings.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,454
Members
452,514
Latest member
cjkelly15

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