Date format problem when open csv file using macro

wallstudio

New Member
Joined
Oct 19, 2010
Messages
36
I have thousands of csv files in a folder. Column A is the date in ascending order. I am trying to open one of them with macro and vlookup rows of date from the csv file and return data to the workbook.

My computer use UK format for date.

The problem is whenever I run the macro, the date format on the csv file are messed up. Some of them display as US format, and some of them display as UK format.

This is a portion of the way they appear:
23/02/2011
24/02/2011
25/02/2011
28/02/2011
03/01/2011
03/02/2011
03/03/2011
03/04/2011
03/07/2011
03/08/2011
03/09/2011
03/10/2011
03/11/2011
14/03/2011
15/03/2011
16/03/2011
17/03/2011

However, there will be no problem if I click and open the same file directly.

The macro is :

Sub OpenFile()
Workbooks.Open Filename:=Range("A13") & Range("A12") & ".csv"
ThisWorkbook.Activate
End Sub​

A13 is the path and A12 is the name of the file which needed to be opened.

Anyone know what's wrong? Thanks.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try:

Workbooks.Open Filename:=Range("A13") & Range("A12") & ".csv", Local:=True

to preserve the UK dates.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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