I need to loop through a directory of .csv files, retrieve a piece of information from each one and compile in a new .xlsx file.
The Dir() function is bailing well before looping through 500 files.
My solution based on this thread: VBA code to loop through files in a folder.
Apparently, while this function was executing, another thing (I assume a Word document I was writing) was telling the macro to stop with no error code. It was exiting out of a while -> wend loop leaving the last document the function visited opened and not executing the close statement. I confirmed this running the macro without anything else open.
If the Dir() function stops execution before checking every file in a directory, close other MicroSoft applications.
What exactly is going on? Is there a way to further mitigate the problem?