Results 1 to 4 of 4

Combining multiple files to workbook from folder, including subfolders

Threaded View

  1. #1
    Registered User
    Join Date
    03-03-2015
    Location
    Finland
    MS-Off Ver
    2016 x64
    Posts
    5

    Combining multiple files to workbook from folder, including subfolders

    Hello,

    I'm fairly new to Excel when it comes to VBA programming and I need bit of help with some code.
    I have code that combines all excel files from folder into one workbook. Each file to it's own sheet in workbook.

    Folder where I have files is D:\Test\ (+subfolders D:\Test\1\, D:\Test\2\ etc.. )

    Code works fine to all files what are in D:\Test\, but how can I get it, so that it also searches files from subfolders in directory D:\Test\

    Many thanks in advance

    Here's the code:
    Sub HaeData()
    Path = "D:\Test\"
    Filename = Dir(Path & "*.xls")
    Do While Filename <> ""
    Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
    For Each Sheet In ActiveWorkbook.Sheets
    Sheet.Copy After:=ThisWorkbook.Sheets(1)
    Next Sheet
    Workbooks(Filename).Close
    Filename = Dir()
    Loop
    End Sub
    Last edited by Leith Ross; 03-03-2015 at 02:07 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. Adapt macro to create list of all PDF files in folder, including subfolders.
    By Glensafro in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2013, 06:33 AM
  3. [SOLVED] Amending various excel files including those in subfolders MACRO
    By gonzalraf in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-20-2013, 02:15 PM
  4. Macro to search folder including subfolders for file and open
    By kiraexiled in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2012, 02:45 PM
  5. Counting files in folder including subfolders also and folder size
    By mido609 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 03:26 PM

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