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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try using
VBA Code:
.Cells(newRow, 5).Value = CDate(DateSubmitted)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

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