Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Count of workbooks in a directory

I need to get a count of the number of workbooks in a
directory I specify.

I see an example someone else used (after a ChDir
command):

CountA = Application.Workbooks.Count

but this doesn't work and I can't see how the code would
look to count the number of workbooks only in a directory
I specify.

Thanks for your help. I'm new and stupid.

David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Count of workbooks in a directory

Try this

Sub test()
Dim foldername As String
foldername = "C:\Data"
With Application.FileSearch
.NewSearch
.LookIn = foldername
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
MsgBox .FoundFiles.Count & " Excel files were found"
Else
MsgBox "There were no files found."
End If
End With
End Sub



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"David" wrote in message ...
I need to get a count of the number of workbooks in a
directory I specify.

I see an example someone else used (after a ChDir
command):

CountA = Application.Workbooks.Count

but this doesn't work and I can't see how the code would
look to count the number of workbooks only in a directory
I specify.

Thanks for your help. I'm new and stupid.

David



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
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Help with Macro & Directory Dave Excel Discussion (Misc queries) 1 June 20th 07 03:34 PM
Directory Jeff Excel Discussion (Misc queries) 1 October 5th 06 04:51 PM
Change directory Jeff Excel Discussion (Misc queries) 6 September 27th 06 04:08 PM
Display 2 formulas from source workbooks to destination workbooks Excel_seek_help Excel Discussion (Misc queries) 4 April 27th 06 08:13 PM


All times are GMT +1. The time now is 08:13 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"