Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to copy files names in a column from one directory to another directory VBA Paul B[_3_] Excel Programming 4 November 10th 08 01:54 AM
Using VBScript to list all folders in a directory and files ... scriptman Excel Programming 1 July 23rd 07 02:49 PM
Opening all files located in a specific directory DaSo Excel Programming 2 January 25th 05 08:05 AM
Reading files on a specific folders Jaime[_3_] Excel Programming 2 August 11th 04 05:00 PM
Open files from specific directory John Rawlins Excel Programming 1 October 16th 03 04:03 PM


All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"