Write a macro to modify date formatting

easbury

New Member
Joined
Jun 7, 2011
Messages
7
I am having some trouble getting a date in a correct format. I need a macro to change the format. Currently I have an instrument at outputs data into Excel and gives the date in this format: 23.Feb.2011. I need the date to be in MM/DD/YYYY format: 02/23/2011.
This will always start in cell B3 and will need to continue until there are no other entries in the column.

Any suggestions?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Code:
Sub Convert_To_Dates()

    Range("B3", Range("B" & Rows.Count).End(xlUp)).Replace ".", " "
    Range("B:B").NumberFormat = "mm/dd/yyyy"

End Sub
 
Upvote 0
You can do this easily without using a macro. Select the column with your "dates" and then click Data/Text To Columns on the menu bar. When the dialog bog appears, click Next twice and then, on that (Step 3) dialog page, look at the set of OptionButtons in the upper right corner... select the Date option and select DMY in the drop-down box next to it, then click the Finish button. Your "date" entries will now be real dates that you can format anyway you want.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

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