Changing the Date Format of a text box of a userform when feeding data to the Excel sheet

KTSARA

New Member
Joined
Nov 18, 2019
Messages
34
Hello experts,

I have a userform with several date text boxes. I added the text "dd/mm/yyyy" to the text box, so that user will enter the date in that format, but when the date is entered to the excel sheet, the date is displayed in the format of "mm/dd/yyyy". When the user enters 2nd of March in 2020 (02/03/2020), it will display in the sheet as 3rd of February 2020 (03/02/2020). I tried to change the format of the column to Short Date format (dd/mm/yyyy), but still the date is displayed in the "mm/dd/yyyy" format. Is there a way to change this? I found the below code from a thread, but couldn't change it to match my need. Any help from you is highly appreciated.

VBA Code:
Cells(endRow, 1) = DateValue(Format(TextBox1.Value, "dd/mm/yyyy"))

This is my code to enter the date into the excel sheet after clicking the submit button of the userform.

VBA Code:
wsServiceRegistry.Cells(emptyRow, 2).Value = ServiceDateTextBox.Value

Thanks a lot in advance
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try using CDate:
VBA Code:
Cells(endRow, 1) = CDate(TextBox1.Value)
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,873
Members
449,130
Latest member
lolasmith

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