Goodday
I have a list of CSV files -- I know how to get the list of the file names into an array and then start to read each file. However I would like the order of the file names in my list to be in the order Oldest to Newest. Below is the code I use for the list of files- any help is much appreciated
Code:Function GetFileList(FileSpec As String, FileArray() As Variant) As Variant 'Where FileSpec = PathToFiles & "\*.csv" Dim FileCount As Integer Dim FileName As String On Error GoTo NoFilesFound FileCount = 0 FileName = Dir(FileSpec) If FileName = "" Then GoTo NoFilesFound Do While FileName <> "" FileCount = FileCount + 1 ReDim Preserve FileArray(1 To FileCount) FileArray(FileCount) = FileName FileName = Dir() Loop GetFileList = FileArray Exit Function ' Error handler NoFilesFound: GetFileList = False End Function







Reply With Quote
Bookmarks