VBA Date Format - Month / Day / Year

I want to present today's dates as follows: 01/23/2016 month / day / year. I wrote the code below, but the result is 01/23/2016. Can someone help me? Thanks

ActiveSheet.Cells (1, 2) = Format (Date, "mm / dd / yyyy")

+4
source share
1 answer

The code you use enters something into an Excel cell. Excel recognizes that it is a date and will display the date according to the default settings.

To display a date with your preferred format, you need to format the cell that displays the date, not the data entry string.

ActiveSheet.Cells(1, 2) = Date
ActiveSheet.Cells(1, 2).NumberFormat = "mm/dd/yyyy"
+9
source

Source: https://habr.com/ru/post/1626064/


All Articles