+ Reply to Thread
Results 1 to 1 of 1

Copy data from multiple directories

  1. #1
    Registered User
    Join Date
    02-09-2004
    Location
    The Netherlands
    Posts
    46

    Copy data from multiple directories

    Hello all,

    I want to copy data from multiple files from multiple subdirectories. How can I create a loop that searches all subdirectories and opens all files of which the filename contains a certain text?

    Right now, my code looks something like this:

    Sub Macro1()
    path = "C:\"
    datafile= Dir(path)
    While datafile <> ""
    Workbooks.Open (path & datafile)
    'some copy/paste-actions
    Windows(datafile).Activate
    ActiveWindow.Close
    datafile= Dir
    Wend
    End Sub

    but it only searches one directory, while my folders look something like this:
    C:\folder1\
    C:\folder2\
    C:\folder2\folder21\
    C:\folder2\folder22\
    C:\folder3\folder31\folder311\
    C:\folder3\folder31\folder312\
    C:\folder3\folder31\folder313\folder3131\
    C:\folder3\folder31\folder313\folder3132\
    etc.

    The files are everywhere, some just one subdirectory deep, some 7 or 8. How can I search every directory for every file that meets my criteria? In other words, how can I keep changing my 'path'?

    TIA,

    Annet
    Last edited by Roadie; 03-07-2005 at 03:51 AM.

+ 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