![]() |
Copy files in sub folders to a specific directory
Dear experts:
I got more than 50 subfolders located under the following main folder's path: C:\test\MainFolder\... ....SubFolder_1 ....SubFolder_2 ....SubFolder_3 ....SubFolder_4 ....SubFolder_n There is (1) one xlsx-file in every subfolder. I now would like to be able via a Macro to copy the xlsx-files located in the sub folders directly into the following directory: C:\test\MainFolder. Is this feasible? Help is much appreciated. Thank you very much in advance. Regards, Andreas |
Copy files in sub folders to a specific directory
You can use the Name function, from help
Name oldpathname As newpathname something like this, untested! s1 = C:\test\MainFolder\SubFolder_#\myFile.xls" s2 = C:\test\MainFolder\myFile" for i = 1 to 50 sOld = replace(s1, "#", cStr(i)) sNew = s2 & "myFile_" & right("0" & i, 2) & ".xls" Name sOld as sNew Next Regards, Peter T "andreashermle" wrote in message ... Dear experts: I got more than 50 subfolders located under the following main folder's path: C:\test\MainFolder\... ...SubFolder_1 ...SubFolder_2 ...SubFolder_3 ...SubFolder_4 ...SubFolder_n There is (1) one xlsx-file in every subfolder. I now would like to be able via a Macro to copy the xlsx-files located in the sub folders directly into the following directory: C:\test\MainFolder. Is this feasible? Help is much appreciated. Thank you very much in advance. Regards, Andreas |
All times are GMT +1. The time now is 05:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com