Hello All,
I have been after this project for quite some time and I feel that someone on here with the correct knowledge will be able to assist me. My googlefu is not good enough for VBA projects I guess. I know this will be long winded but please bear with me. I am looking to make a VBA macro script that will download data across multiple books and import them into a master book. From there I can just cut and paste the relevant data to another master book (would be nice to just import it directly to the last book but I know that is asking for a lot so I am ok with just going to the first master and ill just hand copy to the 2nd master)
The work books are sent every week, there is one folder lets call it USA and then from there, there are 50 states so 50 subfolders within the USA folder.
USA/AL
USA/AK
USA/AR
So on and so forth, in each sub folder there are years, 2016-2019 (where all the old sheets I’ve already downloaded and inputted into the master sheet goes, we can ignore these). The rest of the subfolders are basically monthly reports so for lets say April there will be a total of 4 subfolders named by their state-code-date (example: AL065-00704032019) each week the number AL065 will jump up one these are all downloaded auto magically. So for April my subfolder for USA/AL will look like so:
USA/AL/2016 (ignore)
USA/AL/2017 (ignore)
USA/AL/2018 (ignore)
USA/AL/2019 (ignore)
USA/AL/AL065-00704032019
USA/AL/AL066-00704132019
USA/AL/AL067-00704232019
USA/AL/AL068-00704302019
In each folder it consists of 3 files, 1 .xls (ignore) 1 .xlsx (the data I want is from this sheet) and 1 .pdf that confirms the data on .xlsx is true and correct
So USA/AL/AL065-00704032019 will have the following in its folder:
AL0065-00704032019-PLSC.xls
AL0065-00704032019-PLCRR.XLSX
AL0065-00704032019-PLCR.PDF
After looking at the structure of the folders and deducing what I needed, I will need the VBA script to do the following. I don’t care if I have to run the macro once in every state subdirectory at least I wont have to open files and cut/paste into the master sheet. But in short I need the functions:
Access the
USA directory
Scan through and ignore all the years sub folders. Open only the newest directory:
USA/AL/AL065-00704032019
USA/AL/AL066-00704132019
USA/AL/AL067-00704232019
USA/AL/AL068-00704302019
So in this case the folder would be USA/AL/AL068-007040302019 (4/30/2019 will be the last date modified shown in the operating system file explorer window)
Scan through the folder and open the one .xlsx file and copy sheet: “Monthly” cell range: C6:F11
Ignoring any blank cells or anything that starts with “Enter Voyage Number”
<strike>
</strike>[/FONT]
So the VBA script will open up and copy cells C6-G7 respectively and any entry after labeled “Enter Voyage Number” will be excluded.
This will then put data into a master sheet that I can just open up and all values from all 50 folders will already be in one sheet for me to copy into a another sheet.
I have banged by head doing this multiple ways and it does not work, some scripts ive modified doesn’t work, or some will require me ot manually select the file myself.
Thank you please let me know if you have any questions
I have been after this project for quite some time and I feel that someone on here with the correct knowledge will be able to assist me. My googlefu is not good enough for VBA projects I guess. I know this will be long winded but please bear with me. I am looking to make a VBA macro script that will download data across multiple books and import them into a master book. From there I can just cut and paste the relevant data to another master book (would be nice to just import it directly to the last book but I know that is asking for a lot so I am ok with just going to the first master and ill just hand copy to the 2nd master)
The work books are sent every week, there is one folder lets call it USA and then from there, there are 50 states so 50 subfolders within the USA folder.
USA/AL
USA/AK
USA/AR
So on and so forth, in each sub folder there are years, 2016-2019 (where all the old sheets I’ve already downloaded and inputted into the master sheet goes, we can ignore these). The rest of the subfolders are basically monthly reports so for lets say April there will be a total of 4 subfolders named by their state-code-date (example: AL065-00704032019) each week the number AL065 will jump up one these are all downloaded auto magically. So for April my subfolder for USA/AL will look like so:
USA/AL/2016 (ignore)
USA/AL/2017 (ignore)
USA/AL/2018 (ignore)
USA/AL/2019 (ignore)
USA/AL/AL065-00704032019
USA/AL/AL066-00704132019
USA/AL/AL067-00704232019
USA/AL/AL068-00704302019
In each folder it consists of 3 files, 1 .xls (ignore) 1 .xlsx (the data I want is from this sheet) and 1 .pdf that confirms the data on .xlsx is true and correct
So USA/AL/AL065-00704032019 will have the following in its folder:
AL0065-00704032019-PLSC.xls
AL0065-00704032019-PLCRR.XLSX
AL0065-00704032019-PLCR.PDF
After looking at the structure of the folders and deducing what I needed, I will need the VBA script to do the following. I don’t care if I have to run the macro once in every state subdirectory at least I wont have to open files and cut/paste into the master sheet. But in short I need the functions:
Access the
USA directory
Scan through and ignore all the years sub folders. Open only the newest directory:
USA/AL/AL065-00704032019
USA/AL/AL066-00704132019
USA/AL/AL067-00704232019
USA/AL/AL068-00704302019
So in this case the folder would be USA/AL/AL068-007040302019 (4/30/2019 will be the last date modified shown in the operating system file explorer window)
Scan through the folder and open the one .xlsx file and copy sheet: “Monthly” cell range: C6:F11
Ignoring any blank cells or anything that starts with “Enter Voyage Number”
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
</strike>[/FONT]
So the VBA script will open up and copy cells C6-G7 respectively and any entry after labeled “Enter Voyage Number” will be excluded.
This will then put data into a master sheet that I can just open up and all values from all 50 folders will already be in one sheet for me to copy into a another sheet.
I have banged by head doing this multiple ways and it does not work, some scripts ive modified doesn’t work, or some will require me ot manually select the file myself.
Thank you please let me know if you have any questions