+ Reply to Thread
Results 1 to 2 of 2

Opening folders inside of folders and pulling data from sheets present.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-03-2013
    Location
    Jacksonville, USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Question Opening folders inside of folders and pulling data from sheets present.

    Hello Excel VBA Gurus!

    I am working on an excel to compile data from separate locations. With the help of many other great minds I have reached this point.

    Sub LoopThroughDirectory()
        Dim MyFile As String
        Dim erow
        fpath = Worksheets(1).Range("B3").Value & "\"
        MyFile = Dir(fpath)
        Do While Len(MyFile) > 0
        If MyFile = "zmaster.xlsm" Then
        Exit Sub
        End If
        Debug.Print Now, MyFile
        Workbooks.Open fpath & MyFile
        Range("A2:D3").Copy
        ActiveWorkbook.Close
        erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        Worksheets("sheet2").Paste Destination:=Worksheets("sheet2").Cells(erow, 1)
        MyFile = Dir
        Loop
         fpath = Worksheets(1).Range("B4").Value & "\"
        MyFile = Dir(fpath)
        Do While Len(MyFile) > 0
        If MyFile = "zmaster.xlsm" Then
        Exit Sub
        End If
        Debug.Print Now, MyFile
        Workbooks.Open fpath & MyFile
        Range("A2:D3").Copy
        ActiveWorkbook.Close
        erow = Sheet2.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row
        Worksheets("sheet2").Paste Destination:=Worksheets("sheet2").Cells(erow, 7)
        MyFile = Dir
        Loop
    End Sub
    At this point this file can pull various spreadsheets from within two folders that I specify in the first sheet, copy them, and then paste them into my spreadsheet side by side. My problem arises that in the final product it will need to look inside of folders within the one specified to find the spreadsheets. Each one of the folders within the specified folder has one spreadsheet and a bunch of unimportant folders.

    Any thoughts?

    Many Thanks

  2. #2
    Registered User
    Join Date
    10-03-2013
    Location
    Jacksonville, USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Opening folders inside of folders and pulling data from sheets present.

    Any Ideas?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 09-12-2013, 09:23 PM
  2. VBA code to open folders and pdf file inside the folders
    By kirtesh250187 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2013, 03:17 AM
  3. Replies: 0
    Last Post: 12-04-2012, 01:01 PM
  4. Arrange or group folders based on the assigned icons to Folders using vba
    By sanits591 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-23-2011, 02:04 AM
  5. Probems putting folders into other folders based on user input.
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-16-2010, 12:16 PM

Tags for this Thread

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