Format column to date

RHONDAK72

Board Regular
Joined
Dec 26, 2007
Messages
133
Is there an easy way to write in some VBA code that will first remove any and all characters from a column that would prevent it from changing the format to date format mm/dd/yyyy?

For example, some cells in the column might contain a space, a special character or even a text string for a note that the user typed next to the date within the same cell. Is there a way to quickly remove any and all characters so that the cells in the column can be formatted into a date mm/dd/yyyy format? Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Dear,

This can be done using formulas, over two steps:
1- extract the numbers only
2- convert the extracted numbers to date format

so, assuming that your input data in cell A1, then use the following formula
=SUMPRODUCT(MID(0&A1, LARGE(INDEX(ISNUMBER(--MID(A1, ROW(INDIRECT("1:"&LEN(A1))), 1)) * ROW(INDIRECT("1:"&LEN(A1))), 0), ROW(INDIRECT("1:"&LEN(A1))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(A1)))/10)

then, use the following formula to convert to date (assuming the extracted numbers are in cell B1)
=DATE(RIGHT(B1,4),LEFT(B1,2),MID(B1,3,2))

Best Regards
M. Yusuf
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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