Changing date format with VBA

Adar123

Board Regular
Joined
Apr 1, 2018
Messages
83
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Hi all,

I have encountered an issue where the Excel not recognizing the dates as dates, I tried to .NumberFormat = "dd/m/yyyy;@" for the whole range but this does not do the job.

If I was to do it manually, a solution is to edit the cell and click enter.

Any thoughts on the solution? Thank you

Book3
AB
1NowNeed
214/9/202014/9/2020
314/12/202014/12/2020
414/12/202014/12/2020
514/12/202014/12/2020
603/12/202103/12/2021
703/12/202103/12/2021
Sheet1
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try selecting the column, clicking Data - Text to Column - Click Next - make sure the "Other" box isn't checked - Click Next and go to the date section and select DMY and click Finish.

You can record the above if you want it in VBA.

You could also try the below if there are no formulas in the column.
VBA Code:
Sub Test()
Columns(1).Value = Columns(1).Value
End Sub
 
Upvote 0
VBA Code:
Columns(1).Value = Columns(1).Value
I tried this as well, also copied in another cell but makes not difference.

Selecting a column as a manual operation would not work for me: I am producing several sheets multiple times a day.
 
Upvote 0
Selecting a column as a manual operation would not work for me: I am producing several sheets multiple times a day.

As I stated you can record yourself doing the Text to Columns to get the code.
 
Upvote 0
My apologies, I misread your earlier email.

Yes, "Data - Text to Column - Click Next - make sure the "Other" box isn't checked - Click Next and go to the date section and select DMY and click Finish" solution worked and I recorded the macro to get the code.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,978
Latest member
rrauni

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