VBA Converting Date From UK to US

Lewzerrrr

Active Member
Joined
Jan 18, 2017
Messages
256
Hi,

I've got a data entry form that loads up the current date "06/07/2022" (which can manually overwritten by a user) however when it inputs into the worksheet it converts it to US system "07/06/2022".

How can I ensure it stays as UK system? It's not a problem once it goes past the 12th of the month as it then automatically converts to General type rather than Date type.

Thanks,

Code:
Private Sub CurrentDate()
   
    Me.txtDate.Value = Format(Now(), "dd/mm/yyyy")
   
End Sub

Private Sub WriteDataToSheet()

    Dim newRow As Long, DateSubmitted As String
   
    DateSubmitted = Me.txtDate.Value
   
    With shData
   
        newRow = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
       
        .Cells(newRow, 1).Value = Me.txtID.Value
        .Cells(newRow, 2).Value = Me.cboCategory.Value
        .Cells(newRow, 3).Value = Me.cboSubcategory.Value
        .Cells(newRow, 4).Value = Me.txtCost.Value
        .Cells(newRow, 5).Value = DateSubmitted
        .Cells(newRow, 6).Value = Me.cboMonth.Value
           
    End With

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,997
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try using
VBA Code:
.Cells(newRow, 5).Value = CDate(DateSubmitted)
 
Solution

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,997
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Thank you for the feedback
 

Forum statistics

Threads
1,176,636
Messages
5,904,165
Members
435,076
Latest member
khoadientu247

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
Top