By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,461 Members | 2,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,461 IT Pros & Developers. It's quick & easy.

Count Files In A Folder

P: n/a
Sue
How can I count the number of files in a folder?

Thanks for all help!!

Sue
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sue,
Try this.

Change
..Lookin = "C:\" to whatever the path to the folder is.
Change "Default Folder Name Here" to whatever folder you wish as default.
Entering the "*" as file extension in the second Input Box
will count all files, otherwise just the extension entered in the box
will be counted.

Public Sub CountFiles()

Dim fs As Object
Set fs = Application.FileSearch
With fs
.Lookin = "C:\" & InputBox("Enter Folder Name", "Folder?", "Default
Folder Name Here")
.FileName = InputBox("FileType", "*.doc, *.mdb, *.xls, *.txt, "*")
' (SortOrder:=1)ASCENDING (=2)DESCENDING
If .Execute(SortOrder:=1) > 0 Then
MsgBox "There were " & .FoundFiles.count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If
End With

Set fs = Nothing

End Sub

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Sue" <sm********@earthlik.net> wrote in message
news:jj******************@newsread1.news.atl.earth link.net...
How can I count the number of files in a folder?

Thanks for all help!!

Sue

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.