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 |
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 |
All times are GMT +1. The time now is 05:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com