There are some exel files in a Folder. The aim is to search for the file with the highest date (in the Format: Fundings " & Format(LMD, "DDMMYY") & ".xls) and open it. E.g. the file names are Fundings 270818, Fundings 110618 and the most recent would be the first one. The code below runs into the error that the "MyFile = Dir(MyPath, vbNormal)" is empty.

```
 Dim MyPath  As String
 Dim MyFile  As String
 Dim LatestFile  As String
 Dim LatestDate  As Date
 Dim LMD  As Date

 LMD = Date

 'Specify the path to the folder
 MyPath = "C:\Users\topal\Desktop\Spreaddeterminierung\Fundings " & Format(LMD, "DDMMYY") & ".xls"

 'Get the first Excel file from the folder
 MyFile = Dir(MyPath, vbNormal)

 'If no files were found, exit the sub
 If Len(MyFile) = 0 Then
     MsgBox "No Sir", vbExclamation
     Exit Sub
 End If

 'Loop through each Excel file in the folder
 Do While Len(MyFile) > 0

     'Assign the date/time of the current file to a variable
     LMD = Date

     'If the date/time of the current file is greater than the latest
     'recorded date, assign its filename and date/time to variables
     If LMD > LatestDate Then
         LatestFile = MyFile
         LatestDate = LMD
     End If

     'Get the next Excel file from the folder
     MyFile = Dir

 Loop

 'Open the latest file
 Workbooks.Open MyPath

 End Sub

```