View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Count files in a Folder!

Speed,

Here's a simple little function to do it

Function FileCount(FolderName As String, _
Optional FileFilter As String = "*", _
Optional FileType As MsoFileType =
msoFileTypeAllFiles) As Long
With Application.FileSearch
.NewSearch
.LookIn = FolderName
.SearchSubFolders = False ' True to include subfolders
.Filename = FileFilter
.MatchTextExactly = True
.FileType = FileType
.Execute
FileCount = .FoundFiles.Count
End With
End Function


Call it like
x = FileCount ("C:\MyTest"
for all file types, or
x = FileCount("C:\myTest",,msoFileTypeExcelWorkbooks)
just for Excel workbooks

--

HTH

Bob Phillips

"SpeeD72" wrote in message
...
Hi guys.

How can a make a formula that gives me the "count" of
files in a Folder?

If it insīt possible in a formula can i make a macro that
gives me this "Count" in a cell? how?

Thanks a lot
SpeeD72