This video demonstrates how to import the most recently created Excel workbook in a specified folder into the current workbook. The solution uses VBA’s FileSystemObject.

Here is the code featured in the video.

Sub ImportMostRecentFile()

Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject

Dim MyFolder As Scripting.Folder
Set MyFolder = fso.GetFolder("File Path for folder containing files")

Dim Fle As Scripting.File
Dim NewestFile As Scripting.File

For Each Fle In MyFolder.Files

    If NewestFile Is Nothing Then Set NewestFile = Fle
        If NewestFile.DateCreated < Fle.DateCreated Then Set NewestFile = Fle

Next Fle

Workbooks.Open NewestFile
ActiveWorkbook.Worksheets("Sheet1").Copy after:=Workbooks("Name of Current Workbook").Worksheets("Sheet1")
ActiveSheet.Name = NewestFile.Name


End Sub


Posted by Chester Tugwell