Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy/ move selected data from workbooks to seperate worksheets or workbooks | Excel Worksheet Functions | |||
Help with Macro & Directory | Excel Discussion (Misc queries) | |||
Directory | Excel Discussion (Misc queries) | |||
Change directory | Excel Discussion (Misc queries) | |||
Display 2 formulas from source workbooks to destination workbooks | Excel Discussion (Misc queries) |