0
votes

I have a form created through VBA in which I need the user to enter the delivery date in the "dd/mm/yyyy" format.

I need the date in the same format to be uploaded to the Excel sheet in the backend, which is linked to the form columns.

However, in the Excel file, the format is automatically changed to the "mm/dd/yyyy" format.

The date formatting in the Excel file is correct. I have cross checked the custom format for the column which stores the dates.

I have passed the following code behind the delivery date column in the form.

Private Sub Del_Date_AfterUpdate()

Del_Date = Format((Del_Date), "dd/mm/yyyy")

End Sub

Date column in the form has a valid date entered for reference
enter image description here

2

2 Answers

0
votes

maybe try running a macro to place the dates in the required column and there after trying to change the formatting in the same macro with the code below;

Range("A1").NumberFormat = "dddd, mmmm dd, yyyy" 'you can manipulate to alter the format you require
0
votes
   I have converted the cell to string. The below code will work for you


 Sub test1()
    Dim ws As Worksheet
    Dim wb As Workbook
    Dim del_date As String

    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Sheet2")

    del_date = "2002-12-04"
    Cells(2, 1).NumberFormat = "@"
    ws.Cells(2, 1).Value = Format((del_date), "dd/mm/yyyy")

    End Sub