+ Reply to Thread
Results 1 to 21 of 21

Simple Macro for Merging Excel Files Into One Consolidated File

  1. #1
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Simple Macro for Merging Excel Files Into One Consolidated File

    Hello!
    I have searched many many threads but did not find exactly what I'm looking for, so apologies if this sounds redundant.

    I have multiple excel files in one folder that I would like merged into a master folder.
    The files to be merged have multiple tabs, but I need just the tab labeled 'IT Upload' to be merged. The columns in the merged files are all the same.

    I have tried the following code but am just getting the headers repeated or no data merged, any help would be appreciated:

    Please Login or Register  to view this content.
    I'm attaching sample files.
    FYI - I'm quite new to this!
    Attached Files Attached Files
    Last edited by Revitigs; 11-22-2016 at 02:44 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    There are a lot of examples around but first you should read and act on the forum rules.
    In your case, read #3.

  3. #3
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Thank you - I have corrected this.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Not thoroughly tested. Check all references (Sheets, Ranges etc) and first try on a copy of your folder/workbooks.
    All workbooks, including workbook with code, need to be in same folder.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Thank you for reviewing this!
    Where do I put in the folder path that contains the files to be merged?

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Copy all your workbooks (= files) into a temporary (for checking purposes) folder.
    Open a new (= empty) workbook (= file), copy the code from post #4 into a regular module in this new workbook and save this workbook into the same folder that your workbooks (= files) are saved.
    Now run the code as is.
    Let us know what needs to be changed.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Sorry for not answering in a more comprehensive manner. I was in a hurry to do other things but that should not be of your concern.
    This line
    Please Login or Register  to view this content.
    tells the code that all the workbooks are in the same folder. So the code will go through all the workbooks in this folder as long as the workbook name is different from the workbook with code.
    As I mentioned previously, just try the code on a temp folder with your workbooks and check the result.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Just noticed in your Post #1 that you want values pasted only. Try this for that
    Please Login or Register  to view this content.
    Last edited by jolivanes; 11-22-2016 at 11:08 PM. Reason: Had wrong number of columns in code

  9. #9
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Thank you - this is getting me so much closer.

    I'm getting the following message box: We can't update some of the links in your workbook right now followed by a runtime error message of "9" subscript out of range.

    I can't change that there are links in the workbooks, but can the code continue past this?

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    That must be the code from Post #4. Did you try the code from post #8?

  11. #11
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Yes, I've tried them both:
    Post #4: returns errored links, the error message of updating links appears
    Post #8: returns values, the error message of updating links appears, the run time error 9 appears and the file to merge remains open

    Thanks!

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Maybe try adding the "AskToUpdateLinks" like so.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Hi Jolivanes,

    I have been following this message thread as well. I want to see the end result, I have the same situation as Revitigs, I want to pull data from one tab from many spreadsheets in a folder, but the only difference for me is I have no links to update and I received "subscript out of Range" error message on this line as listed below:

    Please Login or Register  to view this content.
    I am guessing Revitigs is receiving the same error message on the same row above in the code.
    I am hoping this will help with a solution for Revitigs!

    Thanks
    ==========
    Bigroo1958
    Austin, Texas
    ==========

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    From the code in Post #8:
    Change this line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    and let us know what happens

  15. #15
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Thanks again for the reply, Jolivanes.

    Now, I get the runtime error and the first attempted merged file remains open.

  16. #16
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    What is the sheet in your master file that you want to copy into called?

  17. #17
    Registered User
    Join Date
    03-13-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    The sheet is currently called 'IT Upload'
    This is also what the sheets are called from the files to be merged.

    These can be changed, if it helps.

  18. #18
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    As I mentioned in Post #4, check all references and change as required.
    In your attached workbooks in Post #1 the Sheet your copying into is called "Sheet1" so that's what is used in the code.
    Wherever it has "Sheet1" in the code, change that to the sheet name your copying into. In this case change it to "IT Upload"


    BTW, I made 4 copies of your workbooks that you are copying from and put the code into the "Master" workbook. Put everything into a temp folder.
    Ran the code and it works like a charm.
    Last edited by jolivanes; 11-23-2016 at 06:15 PM. Reason: Additional info added

  19. #19
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    If you have no other changes, this is the code you should use.
    Both sheets, the one to copy from and the one to copy into are named "IT Upload", without quotation marks.
    You copy and paste 8 columns only, from A to H, starting at the second row.
    If any of these assumptions are wrong, let us know.
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Hi Jolivanes,

    I have this code working nicely now, I found my error and is now working on my tab names and on my workbooks.
    Thanks again, this is good and saves a lot of manual work.

    Thanks

  21. #21
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simple Macro for Merging Excel Files Into One Consolidated File

    Good to hear that you have it all working and nice to let us know that it works for you.
    Good luck with it.
    Regards

+ 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: 08-20-2016, 08:57 AM
  2. Replies: 4
    Last Post: 02-12-2014, 06:38 PM
  3. [SOLVED] Excel 2010 VB macro to open all files in folder and run a simple macro
    By MSFLNA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2013, 02:54 PM
  4. Macro to Copy multiple worksheets into a consolidated file
    By Crossy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-11-2013, 02:35 AM
  5. Merging multiple Excel files into tabs of one excel file without having to copy and paste?
    By BrettRCourtney in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2013, 03:43 PM
  6. Merging many excel files in to single excel file
    By jsrakesh4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2013, 02:06 AM
  7. merging csv files into a single xls file
    By RezDan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2012, 02:16 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