January 31, 2019

How to List Recent Files with VBA

How to list recent files with VBA automatically and open the most recent file. This is required when we wish to perform actions like transferring data to the most recent file we have been working on. Watch the video:

Watch this video on YouTube.

Here;s the complete code to open the most recent file auotamically and the some code commented out to list all the recent used files in your worksheet:

Sub displayMostRecentFile()
Range(“A1”) = Application.RecentFiles(1).Name
Workbooks.Open Filename:=Range(“A1”)

‘Application.RecentFiles.Maximum = 5

‘For i = 1 To Application.RecentFiles.Count
‘Cells(i, 1) = Application.RecentFiles(i).Name
End Sub

Further Reading:

Application.RecentFiles property (Excel)

A downloadable sample file for practice:

One thought on “How to List Recent Files with VBA

  1. Hi Sir
    Your tutorials have helped me a lot and I am sure it helped others like me around the world. I had this problem dealing with how to create a timesheet that has only Start: 7:50 Am Finish: 16:00 Break: 40 Minutes.
    Name Start Time FinishTime Break TotalhoursW
    Jason 7:50 AM 16:00 PM 40 Mnt =

    Thank you sir I would be really appreciative if helped on this one.

    Kind Regards
    Jason Dean

Comments are closed.