ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Slow File Search (https://www.excelbanter.com/excel-programming/298562-slow-file-search.html)

stratuser

Slow File Search
 
The code below slows down for several seconds because of
the "LastModified" line, and I can't figure out why, since
there are only a few dozen files involved here. If I take
out that one line, the code executes instantly. Any ideas?


Directory = Range("Inputsubdirectory").Value

On Error Resume Next
With Application.FileSearch
.NewSearch
.LookIn = Directory
.Filename = "*.xls*"
.LastModified = msoLastModifiedLastMonth
.SearchSubFolders = False
.Execute

End With




BrianB

Slow File Search
 
You have given Excel more work to do.
Are the files on a server ? Things usually happen slower if so.
I wonder if checking the date of each file before opening would b
faster. (VB FileDateTime function)

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com