+ Reply to Thread
Results 1 to 32 of 32

VBA to pull data from multiple closed workbooks

  1. #1
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    VBA to pull data from multiple closed workbooks

    good afternoon forum!

    was needing some help with a VBA issue as i have only recently worked with VBA

    I am putting together a 60 day report... pulling data from closed workbooks 60 days prior to current day.

    in attached, i have the file name in cell A1 of sheet 1-60 (this cell uses TODAY function so will change daily)... example of complete filepath: C:\Users\Jean\Documents\Reports\Standard Daily Report 6-23-15.xlsm

    was needing to paste sheet 1 of the closed workbooks (these sheets are titled "Stats for Day") to the appropriate sheet (1-60) of the attached workbook (with the exception of Row 1, because this contains file name... So everything from row 2 to the next row with empty cell)

    all sheet titles of closed workbooks are consistent and the name of these workbooks are consistently in cell A1 of sheet 1-60 of attached workbook.

    Any help is GREATLY appreciated!!!
    Attached Files Attached Files
    Last edited by keith740; 06-28-2015 at 03:16 PM. Reason: better explanation

  2. #2
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    tried using INDIRECT, this works, but 60 open workbooks is a hassle...

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA to pull data from multiple closed workbooks

    My question would rather be - why do you have 60 worksheets? Have you considered putting ALL your data/inputs into 1 file/sheet, and then running summaries from that?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    because the data is being pulled from a daily report that i send out at end of shift

  5. #5
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    or do you mean putting all data into 1 sheet of this workbook (sorry, missed that lol)

    tbh i thought this would be the easiest route but putting all data into 1 sheet is possible sure... whichever is easiest code to write

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA to pull data from multiple closed workbooks

    No, I did mean your live data, collecting that all in 1 workbook/worksheet.

    If that is not practical (I understand it isnt always), then perhaps take a look au the Morefunc add-in, it allows use of INDIRECT from closed workbooks

  7. #7
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    it is not practical (wish it was)

    i will look into Morefunc and let know

    i tried this once before giving up on whole project before and ran into issues, but i will try again... i think this would be best route.

    one question... after going the morefunc route, when i send workbook to others... will they need morefunc to view the data?

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA to pull data from multiple closed workbooks

    when i send workbook to others... will they need morefunc to view the data?
    Yes, it is an add-in that is specfic to that "install"

  9. #9
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    installed it... clicked developer tab...Clicked Addins...
    This opened Addin window... checked boxes Morefunc12 and Morefunc Tools... Clicked OK

    Then in new workbook i typed in cell A1 =INDIRECT.EXT('[Standard Daily Report 6-23-15.xlsm]StatsforDay'!$C$2)

    i then got a popup widow with
    "Compile Error in Hidden Module: modAPI
    This error occurs when code is incompatible with the
    version, platform, or architecture of this application."

    did a quick google and found that there is issues with 64 bit... which i have...

    uugh

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA to pull data from multiple closed workbooks

    I have asked for help from other experts for you....have not encountered that before

  11. #11
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    TY FDibbins
    i am running Office Professional Plus 2010 64 Bit
    Googled some more and seems as code may be only option.

  12. #12
    Registered User
    Join Date
    11-19-2014
    Location
    Northampton, England
    MS-Off Ver
    2013
    Posts
    35

    Re: VBA to pull data from multiple closed workbooks

    Quote Originally Posted by keith740 View Post
    or do you mean putting all data into 1 sheet of this workbook (sorry, missed that lol)

    tbh i thought this would be the easiest route but putting all data into 1 sheet is possible sure... whichever is easiest code to write
    If you were looking to put all the data in one book,
    I found this very useful: http://www.rondebruin.nl/win/addins/rdbmerge.htm

    Then sorted the data to create a summary

  13. #13
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    ty mdwynn, installed and seems it will only pull 30 sheets, was really needing 60... but 30 is a start!

    stumbled across =PULL function by Harlan Grove... has anyone ever used this, or INDIRECT2?

  14. #14
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    Keith

    two things

    does your data for previous days change? it looks/sounds like you can just append the new days and delete the one that drops off instead or trying to get new set of 60 every single day?

    secondly
    are you comparing every sheet individually
    would something like Ford mentioned in post #3 not work?
    instead of working with 60 different sheets
    all you would need is the date in one of the columns?
    this is judging by the total column is only 41.... 41x60 =~2.5k lines is rather managable to have in one sheet
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  15. #15
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    hello Humdingaling!
    yes all 60 sheets will change daily as they will be pulling from the last 60 days report
    Ford was asking if my source data can be consolidated... source data cannot... BUT if code would be easier i can change my new workbook to be consildated.
    Something like attached?
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    struggling to see how you can change hours worked in days you already "processed" ie 1 month ago? but i guess people can put in sheets late or be process it after the fact

    if you dont mind me asking....how does your 60 files get updated?
    could be part of the solution or part of the restriction

    i wouldnt go across, i would go downwards
    it would be easier to code and work with..ie if you want to sumif or countif all the ducks are aligned in one column

  17. #17
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    i will be totalling hours worked across 60 days... totaling total $ raised which will give me 60 day $PH

    i copy/paste raw data to daily report and multiple formulas give the KPI you see in example (Would like to link so automated, but thats future mission)

    I can change to downward np..., but... there would be many rows between filepaths (currently 300 and growing everyday)

    if want to move forward with downward tho...np

    i know this is huge task... was debating on original post because so big... appreciate everyone help either way!

  18. #18
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    so the raw data you copy/paste into daily report
    you don't do 60 times a day every day right?
    if you are doing this 60's times a day, i would say you should include the exporting into summary as part of that exercise.

    am i correct in saying you do this once a day every day? if this is the case could you not just add your newest day down the bottom and delete the first day from the top? that would be much faster and easier than using that many indirects

    really don't think you should be using indirect for what you are doing anyway
    wouldnt your spreadsheet run really slow with that many volatile formulas?
    300x60x11 = 198k cells that would want to update every time you move something, if you do certainly hope you have set calculation mode to manual...

  19. #19
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    no lol, ussually once...if its slow day maybe 3... but never more than 3

    i have no idea if it would run slow tbh... if it would you are right, that is not an option...

    Will VBA use indirect? ( i am vba noob sorry)

  20. #20
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    so best bet would be to manually copy/paste to bottom and delete top?

    Would it be possible to install macro in daily that could do this?

  21. #21
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    once complete, i will have many formulas pulling data... will the deleting bottom and adding top affect these formulas?

    sorry 100 quetions...

  22. #22
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    now that i know how the data is formed/created and used
    will give it a crack tomorrow, shouldn't be to hard or long
    what would help is some sample data (sanitised of course) so i dont have to type gibberish files out to test with

    so best bet would be to manually copy/paste to bottom and delete top?
    Would it be possible to install macro in daily that could do this?
    would do this via macro
    would do two actually
    one to do a full reset...ie all 60 to get started and in case you have to reset the data for whatever reason
    one for daily update (delete the last one insert a new one)

    unless you are using it elsewhere i wouldn't even bother with that sheet 2 you have with the today()-60 formulas, you could do that all in VBA

  23. #23
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    Quote Originally Posted by keith740 View Post
    once complete, i will have many formulas pulling data... will the deleting bottom and adding top affect these formulas?

    sorry 100 quetions...
    depends on what your formulas are...i would say not really...formulas should update accordingly...

    in all honesty for what you are trying to do i would even chuck the data into a table and create a pivot table out of it

  24. #24
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    the macro sounds perfect Humdingaling! Actually better!

    im allmost as lost with pivottables as i am VBA...

    attached is an example of sheet that will need copied (StatsforDay)... i tried uploading entire daily (with name changes) but was too big... if there is a way to get
    actuall daily to you may get a better picture...

    Also, currently the daily allready has some VBA that a great forum member helped me with... will the new macro affect my current VBA?
    Attached Files Attached Files

  25. #25
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    see attached file
    so i went with updating will add the latest down the bottom (meaning the oldest is up the top), as you aren't going to use pivot tables for time being i made a empty row between daily reports as seperator

    update daily will ask you if you want to delete the latest date or not then continue to add todays file
    coded to work with today only
    it can be changed so you select a file instead but thats later if you want it
    will take columns A to M (reduce/extend as required)

    update all
    will ask you if you want to delete all summary's you have on your sheet..ie give you clean slate
    will go thru 60 files to update
    any file missing/not found will be written in the updateall sheet so you can find out which ones didnt work

    for both codes i choose to go with pasting values instead of leaving formulas in
    it may be the cause you want some formulas in some columns but that can be fine tuned later...as your dummy file just gave me a lot of external links
    i didn't want that to be cluttering factor at least in testing phase

    Re: will affect other VBA's
    it should not, from what i gather that are directly on your daily file

    i went and put alot of comments on the code itself so please go and read thru them so you understand what is doing what
    let me know if anything is unclear

    those buttons arent really required but i put them for easier use...change/delete etc as you require

    one thing you may need to do is
    Please Login or Register  to view this content.
    change the line to xlsm in your case
    the sample file was xlsx so i used it for testing

    ps you have a lot of random (yet similar) conditional formats in your sample sheet (seems like you cut and paste all over the place)...excessive conditional formats can really slow performance
    Attached Files Attached Files

  26. #26
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    This is AMAZING Humdingaling!!
    Ran test on today Daily and works fine... will test again tmw and let know.
    Hate to ask because done so much already (If not is np) Any way to add a button or add to current insert button: copy Column AJ of sheet titled CopyPaste1 of daily to new sheet of this workbook?
    either way TY SOO much Humdingaling, i hope someday i can somehow return the favor.

    You are right there is TONS of copypsting in daily, i know there is better ways but this what i got to work.
    I did not know about conditional format, will keep that in mind

  27. #27
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    i should of put this first but as always when experimenting with vba on live data
    save a copy first

    copy Column AJ of sheet titled CopyPaste1 of daily to new sheet of this workbook?
    sounds probably but i dont know exactly what your asking to do

  28. #28
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    in the daily i have a sheet titled CopyPaste1
    Need to copy column AJ from the current day (same day as insert button) daily from this sheet (Daily, CopyPaste1) and paste to 60 day workbook (the one you just installed the VBA) sheet 3
    could we add this to the insert button
    Or maybe make a whole new button (Whichever easiest for you)


    i will be using this sheet later to run SUMIFS

    im horrible at explaining lol (im sure you know from previous posts..)

    But once again if too much trouble, no worries
    Last edited by keith740; 06-30-2015 at 03:48 AM. Reason: clearer

  29. #29
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    yes sounds feasible
    you would just plonk in extra code to copy and paste additional data

    with your sheet copypaste1
    where is the data?...how is it structured?
    i hope its the same number of rows as the daily report
    also since your daily report has more than 1 sheet...would suggest additional re-coding to avoid having issues if you accidentally (or not) save your daily report on a different sheet

  30. #30
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    Tested again and verything working great humdingaling!

    It is more rows unfortunately as we are growing so quickly, this column is list of ALL employees.

    BUT, i think i got around this issue by simply installing a button on daily... seems to be working fine!

    TY SO much Humdingaling, wish i could repay you... You have no idea how bad this was needed!!

  31. #31
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA to pull data from multiple closed workbooks

    glad to have helped


    It is more rows unfortunately as we are growing so quickly, this column is list of ALL employees.
    you can copy it across but it wont align? if it doesnt align you wont know which sheet it belongs to?
    or is this purely for the daily one to see if you have missed anyone? ie rowcheck?

    if that is the case then yes i would suggest you check the daily file instead of the summary file (which is what i think you are doing now?)

    if you do have the time i would suggest you to look into learning pivot tables for analysis work
    if can understand vba then pivot tables should not be a big jump
    anyways best of luck

  32. #32
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: VBA to pull data from multiple closed workbooks

    this sheet will be used for SUMIFS, AVERAGEIFS and whatever else i can find that works to pull total KPI for 1 week, 2 weeks, 30 and 60 days (Which im sure will be posting questions on lol... i have most but the %'s are tricky, but i think i got it)

    indeed i do plan on learning pivot tables... i actually took advanced excel i college, but at time i never thought i would use it soo... now using excel every day, go figure...

    plan on retaking these classes very soon!

    TY again Humdingaling!!
    Last edited by keith740; 07-01-2015 at 08:33 PM.

+ 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. Formula for Master worksheet to pull data from multiple closed workbooks...
    By Batman24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2014, 06:24 AM
  2. Replies: 1
    Last Post: 07-02-2013, 03:42 AM
  3. [SOLVED] Data from closed workbooks (pull func, indirect.ext, etc ....)
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  4. Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. Replies: 0
    Last Post: 09-05-2005, 10:05 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