+ Reply to Thread
Results 1 to 20 of 20

Retrieve data from numerous workbooks inside a Master File

  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
    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Retreiving data from numerous Work Books inside a Master File

    You will find an example of some code which will loop through a folder tree of any complexity on my download page. You might wish to incorporate the principles on which it is built (recursion) to solve your particular challenge.

    Hope this helps.
    Martin

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

    Re: Retreiving data from numerous Work Books inside a Master File

    I can't seem to find the page in which you are referring, can you help with a direct link?

    I have been navigating your pages, but I am not sure what it is called.
    Thanks
    -Staci

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Retreiving data from numerous Work Books inside a Master File

    The basic code structure for what you want if all files reside in the same folder:

    Please Login or Register  to view this content.



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

    Re: Retreiving data from numerous Work Books inside a Master File

    snb, can you walk me through that a little more...

    My files are not in the same folder, they are spread out in 6 different folders, but with a slightly complex file tree...as indicated above...

    So if you show me how to start, I can finish...
    Please Login or Register  to view this content.
    and on and on and on???

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Retreiving data from numerous Work Books inside a Master File

    if you have 6 different folders:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Retreiving data from numerous Work Books inside a Master File


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

    Re: Retreiving data from numerous Work Books inside a Master File

    mrice, not sure how to decipher the code...

    regarding SNB's code...ok so changing SNB's code to work in my example scenerio:
    Please Login or Register  to view this content.
    ok but for the part that says
    Please Login or Register  to view this content.
    each file is named different but each start with "tracker" so I am not sure what to put there? &/or what file is it asking for?

    also, what does this part of the code do?
    Please Login or Register  to view this content.
    and where do I put the file path to where I want to put the data? The "tracker-master" file
    as there are 6 worksheets to be sourced to one spot, so 7 worksheets altogether.

    I am sorry for my ignorance, I am just learning the basics, and this is over my head.
    Last edited by Staci; 03-27-2011 at 06:45 PM.

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

    Re: Retrieve data from numerous workbooks inside a Master File

    Does anyone else understand this code, that would be able to help me make sense of it?

    Is there any information that I have not provided?

    Thanks
    -Staci

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Retrieve data from numerous workbooks inside a Master File

    If the filenames start with "tacker.."

    Please Login or Register  to view this content.
    But what are the sheetnames ?

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

    Re: Retrieve data from numerous workbooks inside a Master File

    ok here is an example:
    Comany/Day Shift/Forklift/Tracker-Forklift
    then worksheets would be...Tracker-Putaway, Tracker-Dock,Tracker-Unload

    Company/Day Shift/Tracker

    so night shift would be
    Comany/Night Shift/Forklift/Tracker-Forklift
    then worksheets would be...Tracker-Putaway, Tracker-Dock,Tracker-Unload

    another example would be

    Comany/Day Shift/Loading/Tracker-Processing
    then worksheets would be...Tracker-Processing,Tracker-Training

    Comany/Night Shift/Loading/Tracker-Processing
    then worksheets would be...Tracker-Processing,Tracker-Training

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

    Re: Retrieve data from numerous workbooks inside a Master File

    Are the file paths too complicated?


    I think I might have confused you. Each of the "Tracker" folders are in different sub folders, so there is 7 file paths that are different.

    Each file will basically look like this:

    o:drive\Company File\"shift"\"Department"\"Tracker-" file

    where the shift & department names changing based upon what tracker it is for...

    Hope that helps clears up any confusion
    -Staci
    Last edited by Staci; 03-28-2011 at 03:45 PM.

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Retrieve data from numerous workbooks inside a Master File

    Maybe it's better to reorganize all those files and put them in one folder.
    You can distinguish them by their filenames.

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

    Re: Retrieve data from numerous workbooks inside a Master File

    Sounds easier than it is, they are department files used by different supervisors. I was just hoping for a way to retrieve the data, without having to keep going and copying and pasting all the data...

  15. #15
    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: Retrieve data from numerous workbooks inside a Master File

    Hi Staci

    I've looked at your attachments and, while they can probably most certainly be resolved by shorthand, with the fewest lines of code required, neither you nor I would likely be able to read them...and, unless the contributor has told you so, assume they've been untested.

    Some contributors offer suggestions...not solutions...it's up to you to try to adapt their "suggested, untested" code to your environment. Of course, if it's untested AND you can't read it AND it doesn't work because of errors, it's difficult to fix it unless you CAN read it...ah well...

    If your issue hasn't been resolved by tomorrow, I'll look at it. Can't guarantee results...can't guarantee short code...if I can find code that works, I CAN tell you it's been tested and the code works on the files I've been presented with.

    While your tree structure is somewhat complex and may require further explanation, I'll work on my understanding of it.

    I'll follow the Thread and get back to you.
    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.

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

    Re: Retrieve data from numerous workbooks inside a Master File

    I appreciate it John, I have been looking and googling everything, and haven't had any luck...
    thanks
    -Staci

  17. #17
    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: Retrieve data from numerous workbooks inside a Master File

    Hi Stacie...I'm glad to help if i can...be back to you.

  18. #18
    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: Retrieve data from numerous workbooks inside a Master File

    Hi Staci

    I've included this code in the attached
    Please Login or Register  to view this content.
    I've also modified ReorgDataV5 to work with all the Tracker folders in the various subfolders.
    Please note you'll need to set a reference to Microsoft Scripting Runtime and you'll need to change this line of code
    Please Login or Register  to view this content.
    The code has been tested in Excel 2000 and 2007 and it assumes the directory tree structure you described. Assuming I understand your issue, this should work for you. Let me know of issues.
    Attached Files Attached Files

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

    Re: Retrieve data from numerous workbooks inside a Master File

    John, I can't thank you enough. This is probably going to save me 2 hours of misc tasks a day.

    I had numerous issues in 2007, but when I used 2003, it worked flawlessly.

    Most of the time in 2007, it would Not Respond, and lock up my computer. I had to restart twice. I do not know the reasons why.

  20. #20
    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: Retrieve data from numerous workbooks inside a Master File

    Hi Staci

    I just reran the procedure in 2007 and it worked as expected. If you wish, do this. I've attached two .jpg's. I'd like you to set some breakpoints in the procedures. Take a look at the pictures...do F5 where I indicated...if it proceeds w/o locking up, do the next F5...when you get to the second .jpg, step through the code (F8)...I'd like to know why it's breaking...running fine here.

    If you have time, get back to me.
    Attached Images Attached Images

+ 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