Is it possible to sort array of files in a folder by Date Modified, oldest to newest.
The output would be a sorted 2D array with date and filename, or two 1D arrays (date and corresponding filename).
The Quicksort methods seem to be for filenames.
Or is it possible to process files in Explorer based on date?
The output would be a sorted 2D array with date and filename, or two 1D arrays (date and corresponding filename).
The Quicksort methods seem to be for filenames.
Or is it possible to process files in Explorer based on date?
VBA Code:
Sub test()
Dim BrowseWindow As FileDialog
Dim folder_path As String
Dim my_FSO As Object
Dim the_folder As Object
Dim file_item As Object
Dim my_array() As Variant
Dim i As Long
'choose folder
Set BrowseWindow = Application.FileDialog(msoFileDialogFolderPicker)
With BrowseWindow
.InitialFileName = ThisWorkbook.Path
If .Show = -1 Then
folder_path = .SelectedItems(1)
Else
Exit Sub
End If
End With
'start
Set my_FSO = CreateObject("Scripting.FileSystemObject")
Set the_folder = my_FSO.GetFolder(folder_path)
'loop
i = 0
For Each file_item In the_folder.Files
ReDim Preserve my_array(i)
my_array(i) = file_item.Name
Debug.Print my_array(i)
i = i + 1
Next file_item
End Sub