Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
list directory in EXCEL Bob Phillips Excel Discussion (Misc queries) 1 January 17th 06 04:23 PM
List of folders in a certain directory woolyhedgehog Excel Discussion (Misc queries) 1 October 19th 05 04:28 PM
lIST dIRECTORY ianripping[_57_] Excel Programming 5 November 12th 04 04:10 PM
Directory List Dominique Feteau Excel Programming 2 July 29th 04 10:50 PM
list box- list all files ina directory suee Excel Programming 9 April 7th 04 02:32 AM


All times are GMT +1. The time now is 01:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"