How to select Excel files ONLY

G

Guest

My Function (below) is working fine -- I'm just using it by entering
=FileCount(Test) -- I see there are optional parameters to refine selection
but don't understand what I am to enter.. What should I do in order
to select ONLY *.xls files?
TIA,
Jim

Only First three lines...
Function FileCount(FolderName As String, _
Optional FileFilter As String = "*", Optional FileType As MsoFileType =
msoFileTypeExcelWorkbooks) As Long
With Application.FileSearch
 
D

Die_Another_Day

Change Optional FileFilter As String = "*", to
Optional FileFilter As String = "*.xls",
That's it

Charles
xl Geek
 
G

Guest

much obilged,
Jim

Die_Another_Day said:
Change Optional FileFilter As String = "*", to
Optional FileFilter As String = "*.xls",
That's it

Charles
xl Geek
 
N

NickHK

Jim,
call the function specifying a FileFilter to override the default.
==FileCount(Test,"*.xls")

NickHK
P.S. Many people find the .FileSearch somewhat flakey in it's results; you
may or may not get the correct result returned.
You could easily rewrite the function using VBA's Dir() function to
guarantee consistent results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top