Thursday, February 10, 2011

Excel having issues with dates importing CSV files

Have you ever had a csv file opened by excel and the dates are in MM/DD/YYY format when you want them in DD/MM/YYYY format?

After going nuts with setting regional settings etc, it seems there's a parameter off by default when you open a csv file with excel in VBA.

Here's what you need to do to open and read csv files with dates if youdo not want USA datye formats.

sMyFileBook = ThisWorkbook.Path & "\MyFile.csv"
Set wbMyFile = Workbooks.Open(Filename:=sMyFileBook, UpdateLinks:=False, ReadOnly:=True, local:=True)
Set wsMyFile = wbMyFile.ActiveSheet

Regards,
Tom Bizannes