+ Reply to Thread
Results 1 to 9 of 9

VBA Combining Data from multiple Workbooks

  1. #1
    Registered User
    Join Date
    11-14-2011
    Location
    NEW YORK
    MS-Off Ver
    Excel 2007
    Posts
    6

    VBA Combining Data from multiple Workbooks

    Hi,

    I found a vba script online that would gather data from multiple worksheets located in one directory/folder and have the same number of columns and layout as my master spreadsheet hosting the vba code and all the data. The issue is that I would like the code to also add a column with the name of the file (workbook) the data in that line was extracted from.

    Can anyone please have a look at the code and send me a revised code with the above addition?

    Thank you very much!!!

    Below is the code I currently have:

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    09-07-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: VBA Combining Data from multiple Workbooks

    Would the formula "=CELL("filename";anyCellReference)" help if you include it in your code?

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Combining Data from multiple Workbooks

    Maybe something like this:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 12-18-2014 at 01:38 PM. Reason: corrected code
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    11-14-2011
    Location
    NEW YORK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Combining Data from multiple Workbooks

    Zekraoui, I do not know how to code at all, so I do not understand what you mean. Can you please elaborate? Or include the full code so I can paste it in VB?

    Thanks!

    JBeaucaire, Thank you for your work!! I copied and pasted your code into a module (and changed the files path), but when I run it, I get a window popup saying "Done" (and an "OK" button). Nothing happened though. No data showed up on the spreadsheet.
    Last edited by yisfromer; 12-18-2014 at 12:32 PM.

  5. #5
    Registered User
    Join Date
    11-14-2011
    Location
    NEW YORK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Combining Data from multiple Workbooks

    JBeaucaire, the problem was that I did not add "\" to the end of the directory. I just fixed that. The problem I am getting now is:
    When I run the code, I receive "Run Tim e Error 438 "object doesn't support this property or method".
    When I click "Debug", it says "can't execute code in break mode". When I click "Debug" again, the following row is highlighted in the code:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Combining Data from multiple Workbooks

    Oops....my bad.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-14-2011
    Location
    NEW YORK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Combining Data from multiple Workbooks

    JBeaucaire, Thank you so much! It works wonderfully!

  8. #8
    Registered User
    Join Date
    09-07-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: VBA Combining Data from multiple Workbooks

    my pleasure! please mark your question as "solved"

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Combining Data from multiple Workbooks

    You're welcome. (hat-tip)

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Combining a data range from Multiple Workbooks
    By circe10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2014, 09:43 PM
  2. combining data from multiple excel workbooks
    By VenomWRX in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2011, 02:15 PM
  3. Combining data from multiple workbooks
    By dhd2005 in forum Excel General
    Replies: 2
    Last Post: 09-21-2010, 02:24 PM
  4. Combining Data from multiple workbooks
    By omniplayer in forum Excel General
    Replies: 5
    Last Post: 01-29-2006, 08:20 AM
  5. Question about combining data from multiple workbooks into one rep
    By BookOpenandUpright in forum Excel General
    Replies: 2
    Last Post: 02-19-2005, 09:06 AM

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