CSV File - Date Formats
Hi Nigel,
You've already received some answers on this but to give you a specific
example (copied from an answer I posted to someone else a few weeks ago):
<<You can get round this easily by specifying, when opening, how you
want each column to be interpreted. In the below example I've said
columns 1 and 2 should be considered as DMY and column 3 should be MDY.
Sub openfiledates()
Dim myFieldInfo As Variant
myFieldInfo = Array(Array(1, xlDMYFormat), _
Array(2, xlDMYFormat), _
Array(3, xlMDYFormat))
Workbooks.OpenText Filename:="c:\temp\temp.txt", _
DataType:=xlDelimited, _
Comma:=True, _
FieldInfo:=myFieldInfo
End Sub
Nigel wrote:
Hi All
I have a CSV file that contains dates held in European format (dd/mm/yyyy).
When I open it manually using Excel, the dates remain unchanged. If I open
it using VBA then the dates are changed to US format where they can... so
01/04/2005 becomes 04/01/2005. However dates that cannot be converted eg
23/03/2005 are left as is. I end up with a mixture of dates and formatting
does reset my dates to the correct format!
How can I avoid this problem?
|