Opening most recent files

tobermory

New Member
Joined
Jun 4, 2012
Messages
46
This is probably impossible, but I'll ask it anyway. Is there a way to open, say, the 10 most recently modified spreadsheets in a particular folder? At my place of work, a new spreadsheet appears every 15 minutes in a specific folder with figures etc related to my job. In a super ideal world, I could copy and paste these figures from the 10 most recent files into a master spreadsheet, so I can monitor relevant fluctuations/changes etc. A long shot, but any help would be gratefully appreciated!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Here is an idea, run some Scripting code to list all the files into a spreadsheet which lists workbook name path and date modified then you could run another code to sort the list into date time order then use the top 10 entries to run the process you need it to.

Code for the first part is shown below:

Sub ListMyFilesinFolder()
'You need to set the Reference to use Microsoft Scripting Runtime
'Select the Tools menu and References
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder
Dim FileName As Scripting.File
'Change the file path to your folder location
SourceFolderName = "C:\Excel"
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
Range("A1:B1") = Array("text file", "Date Last Modified")
i = 2
For Each FileName In SourceFolder.Files
Cells(i, 1) = FileName.Name
Cells(i, 2) = FileName.DateLastModified
i = i + 1
Next FileName
Set FSO = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,749
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top