+ Reply to Thread
Results 1 to 4 of 4

copy files from subfolders

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    copy files from subfolders

    I am currently using this code to find and copy selected files from the folder the workbook is saved in to a new folder:

    If Dir(ThisWorkbook.path & "\" & filename) <> "" Then
                  FileCopy ThisWorkbook.path & "\" & filename, newpath & filename
    Endif
    Can this be extended to search for the file in all subfolders?

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copy files from subfolders

    Hi tryer
    You'll need to do a "recursive" search. The technique is demonstrated in these two links
    http://www.excelforum.com/excel-prog...ster-file.html
    http://www.excelforum.com/excel-prog...orksheets.html
    If you need help adapting let me know.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: copy files from subfolders

    thanks Jaslake, I did some searching and found some similar recursive loops, I'm currently working on adapting them, thanks for the offer of help, I'll certainly come back if I get stuck

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copy files from subfolders

    Hi tryer
    Glad you're running with it...success stories are my payback...good hunting. Keep me posted on your progress. Need help, please let me know.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1