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" <(E-Mail Removed)> wrote in message
news:bbc09306-a044-4a1b-96bc-(E-Mail Removed)...
> 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
|