I have a directory, let's say it's L:\Budget Report\Working File\ and in this directory there are many folders, one for each department (OR7, OR8, ISD, etc.). In each of those department folders there is an excel file called Budget Tool.xlsx And just to point out, there are a couple of odd ball folders in this directory that do not contain that file. I need to make the same changes to the file with the same name in each folder that it exists in.
I have my code written and working perfectly for the changes I need made, but currently I have to change the name of the last folder in the file path of my code and hit run for every one of them individually. There are about 90 of them so that's a little time intensive!
So, what I'm wondering is if there is a way to Loop through all the folders in that directory, and IF the file exists then run the code, if not move to the next folder. It seems like that should be possible.
And in case this will matter, part of the code I run is to copy the Budget Tool.xlsx and rename as Budget Tool Quarter2.xlsx, then the remainder of the code runs on the original basically deleting information and changing dates and things so that it's usable for Quarter3. So the code would need to know to save the new version in the same folder that it's currently in.
Hopefully that makes sense! Any help is appreciated.
I have my code written and working perfectly for the changes I need made, but currently I have to change the name of the last folder in the file path of my code and hit run for every one of them individually. There are about 90 of them so that's a little time intensive!
So, what I'm wondering is if there is a way to Loop through all the folders in that directory, and IF the file exists then run the code, if not move to the next folder. It seems like that should be possible.
And in case this will matter, part of the code I run is to copy the Budget Tool.xlsx and rename as Budget Tool Quarter2.xlsx, then the remainder of the code runs on the original basically deleting information and changing dates and things so that it's usable for Quarter3. So the code would need to know to save the new version in the same folder that it's currently in.
Hopefully that makes sense! Any help is appreciated.