JonRowland
Active Member
- Joined
- May 9, 2003
- Messages
- 417
- Office Version
- 365
- Platform
- Windows
Hi ppl,
Same problem http://www.mrexcel.com/forum/showthread.php?t=560649&highlight=IMPORT+CSV+DATE although I'm using VBA to import CSV file into a Template document.
The CSV contains dates formatted as dd/mm/yyyy hh:mm:ss and when the csv data is copied into my template file the date changes to mm/dd/yyyy hh:mm:ss when the day is less than 13. This is causing me a headache now and wonder how I can ensure that the dates are copied in as expected.
My import code is
<code>
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim MyPath As String
Dim strFilename As String
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ScreenUpdating = False
Workbooks.Open Filename:= _
"H:\Process\Temp\Template.xlsm" ' This is a blank file used for
' the purpose of importing souce data pre-processing
MyPath = "H:\Process" ' change to suit
Set wbDst = Workbooks("Template.xlsm")
strFilename = Dir(MyPath & "\*.csv", vbNormal)
If Len(strFilename) = 0 Then Exit Sub
Do Until strFilename = ""
Set wbSrc = Workbooks.Open(Filename:=MyPath & "\" & strFilename)
Set wsSrc = wbSrc.Worksheets(1)
wsSrc.Copy After:=wbDst.Worksheets(wbDst.Worksheets.Count)
wbSrc.Close False
strFilename = Dir()
Loop
' Deletes original sheet in Template.xlsx which isn't needed
wbDst.Worksheets(1).Delete
</code>
Any ideas plseeeee.
Thx
Jon
Same problem http://www.mrexcel.com/forum/showthread.php?t=560649&highlight=IMPORT+CSV+DATE although I'm using VBA to import CSV file into a Template document.
The CSV contains dates formatted as dd/mm/yyyy hh:mm:ss and when the csv data is copied into my template file the date changes to mm/dd/yyyy hh:mm:ss when the day is less than 13. This is causing me a headache now and wonder how I can ensure that the dates are copied in as expected.
My import code is
<code>
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim MyPath As String
Dim strFilename As String
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ScreenUpdating = False
Workbooks.Open Filename:= _
"H:\Process\Temp\Template.xlsm" ' This is a blank file used for
' the purpose of importing souce data pre-processing
MyPath = "H:\Process" ' change to suit
Set wbDst = Workbooks("Template.xlsm")
strFilename = Dir(MyPath & "\*.csv", vbNormal)
If Len(strFilename) = 0 Then Exit Sub
Do Until strFilename = ""
Set wbSrc = Workbooks.Open(Filename:=MyPath & "\" & strFilename)
Set wsSrc = wbSrc.Worksheets(1)
wsSrc.Copy After:=wbDst.Worksheets(wbDst.Worksheets.Count)
wbSrc.Close False
strFilename = Dir()
Loop
' Deletes original sheet in Template.xlsx which isn't needed
wbDst.Worksheets(1).Delete
</code>
Any ideas plseeeee.
Thx
Jon