Date appears in US format when recalled to a User Form.

Denny57

Board Regular
Joined
Nov 23, 2015
Messages
185
Office Version
  1. 365
Platform
  1. Windows
I use the following code to automatically apply today's date into a cell in a worksheet when a record is added or modified using a User Form

Private Sub Worksheet_Change(ByVal Target As Range)
' Auto Date
Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("A:A").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "L").Value = Date
Else
Cells(Cell.Row, "L").Value = ""
End If
End If
Next Cell
End Sub

The cells in Column L are custom formatted to dd/mm/yyyy format however, when a record is recalled to the User Form, this date appears in mm/dd/yyyy format. I assume that there must be a way to format the appropriate text box in the VBA code, so any help with the coding of this would be appreciated.

I have checked the default date format in Windows 11 and this is set to dd/mm/yyyy.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
The line of code that reads the cell that returns the date to your textbox change the value property of the cell to read Text

Rich (BB code):
Me.TextBox1.Value = Cells(1, 10).Text

This should return exactly what you see in the cell & not it's underlying value.

Dave
 
Upvote 0
The line of code that reads the cell that returns the date to your textbox change the value property of the cell to read Text

Rich (BB code):
Me.TextBox1.Value = Cells(1, 10).Text

This should return exactly what you see in the cell & not it's underlying value.

Dave
Thank you for this. Strangely the problem appears to have been resolved, maybe by coincidence.

I selected File...Advanced.. and then checked and unchecked "Use 1904 date format".

Should the problem return then I will use the VBA code suggested,
 
Upvote 0
Solution

Forum statistics

Threads
1,214,971
Messages
6,122,517
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