2 digit year dates to 4 digit

John_McClane

New Member
Joined
Apr 30, 2013
Messages
27
Hello,

Thanks in advance for looking at my query.

I have a report that lists expiry dates for peoples training courses. It is generated by someone else, I cannot change the way the report is made (even though that would be the simple solution)

I am creating a macro to tidy up the report and to conditionally format the dates to have a traffic light system, however because the dates are 2 digit year dates (e.g 04/04/14) the conditional formatting does not work. Of course, I can change the dates by using error checking but that doesn't seem to record so when I run the macro the dates do not change. They are all xx/xx/20xx. Is there any code I can add to change all the dates to 4 digit with '20' at the beginning of the year?

Any ideas to get the conditional formatting to work would be great! Thank you very much,
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Mohan,

No luck with this I'm afraid, I think because the date has been entered as text Excel doesnt know if the start of the year is 20 or 19 etc.

Any other ideas?
 
Upvote 0
Sub chetan()
[B2].Formula = _
"=iferror(DATE(IFERROR(YEAR(rc[-1]),RIGHT(rc[-1],4)),IFERROR(DAY(rc[-1]),SUBSTITUTE(LEFT(rc[-1],2),""/"","""")),IFERROR(MONTH(rc[-1]),LEFT(RIGHT(rc[-1],7),2))),"""")"
Columns("B:B").NumberFormat = "dd/mm/yyyy"
end sub
 
Upvote 0

Forum statistics

Threads
1,221,444
Messages
6,159,914
Members
451,603
Latest member
SWahl

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