Results 1 to 20 of 20

Retrieve data from numerous workbooks inside a Master File

Threaded View

  1. #1
    Registered User
    Join Date
    03-05-2011
    Location
    Savannah, GA
    MS-Off Ver
    Excel 2003 (work), 2010 (home)
    Posts
    44

    Retrieve data from numerous workbooks inside a Master File

    I would like a macro to loop through a master file, and retreiving specific data. To make it easy: I am going to generically name all my files, but in real life they are named something else. And they all have something similliar about them, as you will see.

    Ok so I have a master folder called:
    for our purposes we will call it Company, then inside I have it seperated into Manager, Day Shift and Night Shift, and then inside each "Shift" files, I have 3 seperate folders we can call "A", "B", & "C", and then inside each one of those folders is a file that starts with "Tracker"...(so there is 6 of them all together, 3 in each shift). And finally inside those "Tracker' workbooks, I have worksheets that start with "Tracker"Would it be possible to have a macro built into a workbook named "Scorecarding" into a workbook named "Tracker-Master"worksheet named "Tracker-Master" in the Manager folder, to bring the data from all the different sources?

    might sound a little complicated but with the help of stanleydgromjr, I have a macro that does function how I want, but only per one workbook, I would just like to loop through all the files.
    http://www.excelforum.com/excel-gene...rmat-data.html

    *please note: we have since modified the Macro, below is the "Final" Macro that works 100% for all the files
    Option Explicit
    Sub ReorgDataV5()
    ' stanleydgromjr, 03/25/2011
    ' http://www.excelforum.com/excel-general/768143-index-match-to-reformat-data.html
    ' ***** The row containg Total has been changed.  Row 2 is now clear to find LC for a date. *****
    Dim ws As Worksheet, wF As Worksheet
    Dim LR As Long, LC As Long, NR As Long, a As Long, aa As Long
    Application.ScreenUpdating = False
    If Not Evaluate("ISREF('Final Format'!A1)") Then Worksheets.Add(Before:=Worksheets(1)).Name = "Final Format"
    Set wF = Worksheets("Final Format")
    wF.UsedRange.Clear
    wF.Range("A1:F1") = [{"Date","Employee Name","Function","Quantity","Hours","AVG."}]
    For Each ws In ThisWorkbook.Worksheets
      If Left(ws.Name, 7) = "Tracker" Then
        With ws
          LR = ws.Cells(Rows.Count, 1).End(xlUp).Row
          LC = ws.Cells(2, Columns.Count).End(xlToLeft).Column
          For a = 4 To LC Step 3
            For aa = 4 To LR Step 1
              If Application.Count(ws.Range(ws.Cells(aa, a), ws.Cells(aa, a + 2))) > 0 Then
                NR = wF.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
                wF.Cells(NR, 1).Value = ws.Cells(2, a).Value
                wF.Range("B" & NR).Resize(, 2).Value = ws.Range("A" & aa & ":B" & aa).Value
                wF.Range("D" & NR & ":F" & NR).Value = ws.Range(ws.Cells(aa, a), ws.Cells(aa, a + 2)).Value
              End If
            Next aa
          Next a
        End With
      End If
    Next ws
    LR = wF.Cells(Rows.Count, 1).End(xlUp).Row
    wF.Range("A2:A" & LR).NumberFormat = "m/d/yyyy"
    wF.Range("E2:F" & LR).NumberFormat = "0.00"
    wF.Range("D2:F" & LR).HorizontalAlignment = xlCenter
    wF.UsedRange.Columns.AutoFit
    wF.Activate
    Application.ScreenUpdating = True
    End Sub
    I am not sure how to loop between all the folders, can someone assist or point me in the correct direction.

    Please view the attachments, as it does provide all of the above data, in a better view, I am not sure how else I can make it make sence so I will enclose a sample workbook (ReOrgDatafv1), so you can see the tasks that it performs.


    Any thoughts, ideas are appreciated...

    Thanks
    -Staci
    Attached Files Attached Files
    Last edited by Staci; 03-29-2011 at 07:04 PM.

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