Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Directory List - Ron de Bruin
Ron
You gave me this macro to get a directory list of files in a folder. Only thing is that the files dont show up in alphabetical order. I could add a separate small macro at the end that would sort them in order, but I was wondering if there is another way to do it. Let me know Dominique Sub test2() Dim i As Long With Application.FileSearch .NewSearch .LookIn = "c:\Data" .SearchSubFolders = False .MatchTextExactly = False .FileType = msoFileTypeAllFiles If .Execute(msoSortOrderDescending) 0 Then MsgBox "There were " & .FoundFiles.Count & " file(s) found." For i = 1 To .FoundFiles.Count Cells(i, 1).Value = .FoundFiles(i) Cells(i, 2).Value = FileDateTime(.FoundFiles(i)) Cells(i, 3).Value = FileLen(.FoundFiles(i)) Next i Else MsgBox "There were no files found." End If End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Directory List - Ron de Bruin
Dominique,
Change If .Execute(msoSortOrderDescending) 0 Then to If .Execute(msoSortByFileName) 0 Then -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Dominique Feteau" wrote in message ... Ron You gave me this macro to get a directory list of files in a folder. Only thing is that the files dont show up in alphabetical order. I could add a separate small macro at the end that would sort them in order, but I was wondering if there is another way to do it. Let me know Dominique Sub test2() Dim i As Long With Application.FileSearch .NewSearch .LookIn = "c:\Data" .SearchSubFolders = False .MatchTextExactly = False .FileType = msoFileTypeAllFiles If .Execute(msoSortOrderDescending) 0 Then MsgBox "There were " & .FoundFiles.Count & " file(s) found." For i = 1 To .FoundFiles.Count Cells(i, 1).Value = .FoundFiles(i) Cells(i, 2).Value = FileDateTime(.FoundFiles(i)) Cells(i, 3).Value = FileLen(.FoundFiles(i)) Next i Else MsgBox "There were no files found." End If End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
list directory in EXCEL | Excel Discussion (Misc queries) | |||
List of folders in a certain directory | Excel Discussion (Misc queries) | |||
lIST dIRECTORY | Excel Programming | |||
Directory List | Excel Programming | |||
list box- list all files ina directory | Excel Programming |