Greetings,
I recently threw together a bit of code that parses text from the most recently modified file in a selected folder. However, the folder keeps track of job tickets at my work, and it can fill up fairly quickly. Right now, 889 .txt files are in the folder to be searched. I have relatively little experience with VBA at maybe 3 months of steady use at work. My implementation takes around 15 seconds to run, and I would like to know if there is a way to speed up this process. This is the implementation currently. I narrowed down the performance bottleneck to this for each loop. I would love to hear thoughts on the matter!
I recently threw together a bit of code that parses text from the most recently modified file in a selected folder. However, the folder keeps track of job tickets at my work, and it can fill up fairly quickly. Right now, 889 .txt files are in the folder to be searched. I have relatively little experience with VBA at maybe 3 months of steady use at work. My implementation takes around 15 seconds to run, and I would like to know if there is a way to speed up this process. This is the implementation currently. I narrowed down the performance bottleneck to this for each loop. I would love to hear thoughts on the matter!
Code:
'loop through each file and get date last modified. If largest date then store Filename
dteFile = DateSerial(1900, 1, 1)
For Each objFile In myFolder.Files
If objFile.DateLastModified > dteFile And Right(objFile.Name, 4) = ".txt" Then
dteFile = objFile.DateLastModified
strFilename = objFile.Name
End If
Next objFile