NickGraham
New Member
- Joined
- Apr 14, 2009
- Messages
- 2
Hi, I'm using some code I found on this forum to open a csv file. One of the columns contains dates and when opening the file using the macro the date format is changed from dd/mm/yyyy to mm/dd/yyyy but only if the date is on or before the 12th month. If the file is opened manually the date format stays as dd/mm/yyyy
The code I am using is:
It looks to me like Excel is defaulting to the US date format but I don't know how to instruct it that the date format is UK. Does anyone know how to fix this?
The code I am using is:
Code:
Sub OpenCompletedWorkItem()
'opens the CompletedWorkItem file
Dim DateToOpen As String
DateToOpen = Format(Date, "yyyy-mm-dd")
'searches for all the CompletedWorkItem files with todays date
With Application.FileSearch
.NewSearch
.LookIn = "J:\Dept\CSU TL\Batch Tracker\Ciboodle Data"
.FileType = msoFileTypeExcelWorkbooks
.Filename = "CompleteWorkItem_" & DateToOpen & "*"
.Execute
'counts the number of CompletedWorkItem files with todays date
i = .FoundFiles.Count
'opens the most recent CompletedWorkItem file
Set wb = Workbooks.Open(.FoundFiles(i))
End With
End Sub
It looks to me like Excel is defaulting to the US date format but I don't know how to instruct it that the date format is UK. Does anyone know how to fix this?