View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Counting files in a folder

Hi
try something like the following:


Sub test()
Dim i As Long
With Application.FileSearch
.NewSearch
.LookIn = "C:\Temp\"
.SearchSubFolders = False
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
Else
MsgBox "There were no files found."
End If
End With
End Sub



--
Regards
Frank Kabel
Frankfurt, Germany


Hawki wrote:
Is there an easy way to count files in a given folder?
TIA...