VBA to change US date format to UK date format

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi everyone

I have a report which have dates in American format YYYY-MM-DD, I need to change the date columns from D to M into UK format DD-MM-YYYY and the end row is various. Some fields may be only text instead of dates.

Please could anyone help how to create this in VBA? Many thanks.
 
Last edited:
Won't that leave the dates that are US dates but look like UK dates the same?
For example 9/11/2017 which would be 11th September in US but 9th November in UK (dd/mm/yyyy).
If you are referring to my code, "No".
In the OP's format 11th September 2017, say, would originally appear as 2017-09-11 and after my code it appears as 11-09-2017 (ie 11th September 2107 in UK format)
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Sorry for wasting your time Peter as I had already re-read the thread and realised that they were in the International format and edited my post as you were posting yours.

Apologies again :(
 
Upvote 0
Thanks all! Scott unfortunately there is still running time error on the cell range.

Peter, your code runs perfectly.

Many thanks to both of your help and advice. I appreciated it very much for all of your help.
 
Upvote 0
It's strange, it looks like they work:

Original dates:
2018-07-02
2018-07-09
2018-07-09
2018-06-26
2018-06-25
2018-06-25
2018-07-02
2018-07-02
2018-07-09
2018-10-08
2018-10-15
2018-10-15
2018-10-22

<tbody>
</tbody><colgroup><col></colgroup>


After Macro:
02-07-2018
09-07-2018
09-07-2018
26-06-2018
25-06-2018
25-06-2018
02-07-2018
02-07-2018
09-07-2018
08-10-2018
15-10-2018
15-10-2018
22-10-2018

<tbody>
</tbody><colgroup><col></colgroup>
 
Upvote 0
What results are you considering to be incorrect?
 
Upvote 0
From my person point they are correct but as you are VBA experts, you may be able to find out why it works or not.
 
Upvote 0
They are all correct as far as I can see which is why I asked.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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