ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why are some dates changing and not others? (https://www.excelbanter.com/excel-programming/379875-re-why-some-dates-changing-not-others.html)

RichardSchollar

Why are some dates changing and not others?
 
If I were you, I would change the file extension of what you are
attempting to import from .csv to .txt (you can do this manually in
Wondows Explorer or code it into VBA) and then open it using
Workbooks.OpenText where you can specify how to interpret columns (see
the VBA help - eg D/M/Y order etc).

Richard



C Flynn wrote:
I have a routine that imports data from a csv file into an xls file which
contains the import code. The data i'm importing contains a colunm which
contains dates. "01/03/2002 00:00" (without the speech marks). for some
reason when the following code opens the file, some dates have changed. for
example the above date becomes "03/01/2002 00:00:00" this problem is driving
me crazy because it only affects somes dates but not all so i can't change my
code to reverse the month and day around. Please help.

Hers the code i'm using:
Sub StockP()
'
Dim Target As Workbook
Dim Source As Workbook
Dim FName As String
Dim MyPath As String
MyPath = "C:\Stacker"
Set Target = ThisWorkbook
ChDrive MyPath
ChDir MyPath
FName = Dir("*.csv")
If Len(FName) = 0 Then
MsgBox "Stock file not found" & vbNewLine & "Try Exporting a used stock
file from Pinnacle to C:\Stacker folder first"
Exit Sub
End If
'
Application.ScreenUpdating = False
If Len(FName) = 90 Then
Workbooks.Open Filename:=FName
etc



--
C Flynn
UK




All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com