I am trying to write a macro that will index the contents of a folder. It starts with a Input Box for the root directory (in Windows), and another Input Box for the file extension to be indexed. It then fills column A with the filenames from the designated extension and the directory of each file. It then goes into the subfolders in the directory and does the same. It works great, except...
The problem is it only searches the first level of subfolders. I need to search ALL levels of subfolders. If I knew there were 5 levels, I could just make a 5 level nested loop, but I don't know how many levels there might be.
I am considering redefining my root folder each iteration and using the infamous GoTo command to just start over with the new root folder.
Now it is your turn to dissuade me from using GoTo and show me how else this could be accomplished. Complete code is below. You will probably need to enable the Microsoft Scripting Runtime in the VB Editor with the Tools>References menu.
Thanks in advance for your help!![]()
Please Login or Register to view this content.
Bookmarks