title: Finding the newest file in folder
body: <p>I want to find the newest file a particular folder.  </p>
  
  <pre><code>Sub FindFile()
  
  Dim MyFolder As String
  Dim MyFile As String
  Dim NextRow As Long
  Dim MyDateTime As Date
  Dim MyDate As Date
  
  Set sh1 = Worksheets("Sheet1")
  
  MyFolder = "C:\"
  MyFile = Dir(MyFolder &amp; "*.pdf")
  
  NextRow = 1
  Do While Len(MyFile) &gt; 0
      MyDateTime = FileDateTime(MyFolder &amp; MyFile)
      sh1.Cells(NextRow, "A").Value = MyFolder &amp; MyFile
      sh1.Cells(NextRow, "B").Value = MyDateTime
      MyDate = Int(MyDateTime)
      If MyDate = Date Then
          sh1.Cells(NextRow, "C").Value = "Y"
      End If
      NextRow = NextRow + 1
      MyFile = Dir
  Loop
  
  End Sub
  </code></pre>
  
  <p>This lists all the files in the spreadsheet.  Without using Sort, is there a better way I can just grab the newest filename and assign it to a variable?  </p>
  
  <p>*Ideally I'd like to find the file without even have to list them.</p>