Hi maybe you can help me on this matter. The code below looks for the last modified file in a certain folder and opens that workbook. The thing is now that the files are saved under the filename "ubs dd-mm-yyyy".....as you can see they are saved with UBS + the date where they are saved. I would like VBA to look in the folder for the file with the most recent date of type "ubs dd-mm-yyyy" - right now it just looks for the last modified, which is more prone to errors if someone opens an old file and saves it.....
Anyone :thanx: :rambo:
Code
Sub hentUbs()
Findes
End Sub
Function Findes()
Dim blah As FileSearch
directory = "U:\FI-Euro\IG Corporates\HF\Tool Construction\UBS"
Set blah = Application.FileSearch
With Application.FileSearch
.NewSearch
.LookIn = directory
.LastModified = msoLastModifiedAnyTime
.Execute msoSortByLastModified, msoSortOrderDescending
End With
MsgBox blah.FoundFiles(1)
Workbooks.Open Filename:=blah.FoundFiles(1)
End Function
Display More