Comments on: How to merge multiple Excel files into one

Merging multiple Excel workbooks into one file could be a cumbersome and long process. So, which is the best way to handle the problem: copy the sheet tabs, run VBA code or use a special tool? Continue reading

Comments page 8. Total comments: 249

  1. This errors out after 10 worksheets from 10 different workbooks if the worksheets all have the same name. Can this be fixed?

  2. Using sumif formula how to calculate total from two columns?

  3. Thank you so much for this. Could I possibly ask that the author breaks down the code to tell us how it functions. IN general for the code to copy over sheets into one workbook. It is great.

  4. the idea of combining workbooks into one is not just limited to worksheets, but also modules, userforms, thisworkbook, macros and the like... i'll worry about cleaning up once they are merged. But so far, i only know of a tool that combines sheets and leaves all the rest. Anyone know of a comprehensive book merge?

  5. I am trying to merge three Excel workbooks into one. I followed along with what the "How to Merge Excel Files With VBA" section said above about adding the macro. I am stuck on step 2 under "How to use the MergeExcelFiles macro". When I hit "Run", a message pops up saying "Compile Error Syntax Error" and in the code I entered, the "Sub MergeExcelFiles()" part is highlighted in yellow and has a yellow arrow pointing to it.

  6. I have 4 excel files on Sharepoint and want to create a summary report on 5 excel. is that possible? if yes then please share the process.

  7. Does anyone know how to compare two excel files merge them in VBA
    Basically i want to do the following
    Eg. File 1 firstname city
    Jack New york
    Joe Chicago
    File 2 firstname city
    Jack Boston
    Joe Chicago
    Jim San Diego

    Merged File firstname city
    Jack Boston
    Joe Chicago
    Jim San Diego

    Basically update and append
    Please let me know if anyone has done it or can do it

  8. I was able to use the code, it is very helpful. Thank you for this.

  9. Dave's code was extremely helpful, thank you!

  10. Hi! I'm trying to use the VBA but when I run it, it says Compile error: Invalid outside procedure.
    .. Do I need to change/ update something in the code to assign my directory etc?
    Thanks

    1. Lisa:
      Sounds as if there is some code outside the SUB at the top of the routine and the END SUB at the bottom. Check and see if this is the case.

  11. Thanks very much!

  12. hello.
    i need to combine multiple excel files into one excel sheet. is there any code.?

  13. Hi, Great Post for Merging Multiple Excel Files into One. But i have a Doubt everyone not able to write VBA Script. so i Think synkronizer Excel Sheet Tool is useful for compare, merge your excel sheet files without any coding. thanks

  14. 1. I need to calculate and post some figures into two different files?
    2. Can I email you the documents or files which I am talking about?
    3. I need to draw up in excel the cash flow.
    4. Is it possible for to add macro into IQ Retail so that i can able to
    calculate stock ordering Or how do I add up macro into IQ Retail?
    Can I be may be open up teamviewer and show me?

  15. The Macro way worked well for small workbooks. Only for workbooks that are really big with dashboards and charts and contain multiple worksheets I keep getting the following message:
    (The name "xxxx" already exists. Click Yes to use that version of the name, or click No to rename the version of "xxxx" you're moving or copying.

    the message keeps on popping up and it is preventing the merge of the workbooks. I guess it's because the files contain multiple worksheets and there might be some worksheets with the same name, not sure!

    Thank you,

    Anita Yalda

  16. Just an FYI - perhaps it's my older Excel version but I did the first steop, but even though I forgot to check off "Create a copy", my sheets remained in the source file anyway. Only dif - my source file closed itself. But when going back to my File Explorer, there it was, all still intact.

  17. Not sure but might have posted the sheet selection backwards.
    It says:
    To select adjacent sheets, hold the Ctrl key and click on each sheet tab individually.
    To select non-adjacent sheets, click on the first sheet tab that you want to copy, press and hold the Shift key, and then click on the last sheet tab. This will select all worksheets in between.

    I'm pretty sure it's the opposite.
    For NON-adjacent cells use Ctrl and for ADJACENT cells, use SHIFT.
    Also note is says in the non-adjacent part "will select all workbooks in between" - so I think it's just a typo on the word 'adjacent' and 'non-adjacent'

    1. Hi Nan,

      You are absolutely right, just a silly typo - the 'non' prefix was in the wrong place :) Thank you very much for pointing this out, fixed!

  18. This worked beautifully! THANK YOU! Truly a lifesaver!

  19. None of these procedures seem to work on Mac Excel 2011. Many of the Excel tools do not seem to be available. The Vba macro doesn't seem to run. I have 100 separate Excel files that I want to merge into one.

    Neal

  20. i face an error every time i choose more than 2 files "Run Time error 1004 Application-Defined or object-defined error " and it only merge 2 files and open the third in another window >>>> i do not no if it maters but it can not rename the third worksheet . THANKS >>> Need your urgent support plz

  21. Is there a way to merge all the data on the same workbookor a file of your choosing? This macro creates a new workbook. I have other macros on the original workbook and would like to add all the data from the excel files into the current workbook. Thanks.

  22. Regarding the vba method, is it possible to build a code to only transfer the 1st tab from each excel file? Ex: 1st file contains Data1 tab and Result1 tab. 2nd excel file contains Data2 tab and Result2 tab. I'd like to create an excel file that will capture Data1 tab and Data2 tab only. This is just an example, the actual # of files are a lot more than 2. Thank you.

  23. Is there any possibility to get just the "Copy sheets" add-in wihtout having to buy the whole "Ultimate Suite"?

  24. The above VBA coding helped me but Is it possible to also merge hided sheets of the files when we merge the multiple file. Please help me with coding.

  25. Can I do the inverse? I mean, I have a file full of different dates but I need to unmerge them by date, each one in a individual file. (Not manually)

    1. Hi Fernando,
      I hope I am right in thinking that ‘Split Table Wizard’ from ‘Ablebits Ultimate Suite’ might be helpful in dealing with your task since the tool provides an opportunity to extract the data from a table and direct those pieces of information to other locations, including newly created Excel workbooks: one per each. Please note that, if you work with dates, opting for ‘Key values’ in ‘Step 4’, will result in titles like ‘43739’ and ‘43956’ instead of ‘October 1, 2019’ and ‘May 5, 2020’ respectively.

  26. I love you. The macro worked PERFECTLY!

  27. Can this macro be enhanced to also include .csv files? Most downloads I perform save the files as .csv after which a merge into one spreadsheet would be invaluable.

    Thanks

    1. Yes, I've tried it and it's working.
      You just need to edit the code so the file choose will accept also CSV.

  28. From the source files i need a particular sheet not all the sheets . Suppose three product files , (product1 , product2 and product3) all the files has many sheets like sales,employees, expenses and so on. But i need only sales sheets from all the 3 product files into one work book (not in one work sheet)

    1. Hi Hari,

      Please see the last example in this tutorial that shows how to copy selected sheets to one workbook.

      1. i need the same macro
        from the source files i need a particular sheet not all the sheet but i am not able to find your answer about the last example. could you provide the link plz

  29. Hi; when running the VBA script on mac excel 2011, version 14.7.0, I get the message "Runtime error 1004: The method GetOpenFileName to object '_Application' failed".

    Do you have any proposal for how to fix this?

    Best regards
    Wilhelm

    1. Same problem on Excel V 16.21.1 on a Mac. Maybe this command is not supported on a mac?

      1. Excel for mac doesn't support accessing the file system in the same way Windows does. VBA for Mac also doesn't debug very well. You're better off trying to run a script outside of VBA if using MacOS

  30. Dear Sir/ Madam

    I have to combine 30 excels files into one mail excel file. it is requested to kindly provide VBA code script.

    Regards

      1. I could combine the files, but the images/logos were missing in the excel.There is this messages, images cant be diplaed

  31. Hi,
    Multiple sheets can be easily merge into one by a tool called as Power Query, its a separate tool needs to be download from Excel.
    Power query lets you to combine multiple sheets into one and helps you to compile the data.
    There is also a tool called as Power Pivot, which helps to apply Pivot on multiple sheets together.

    1. Hey that is an interesting idea - could you elaborate?

      1. Google "combine multiple excel files into one using power query"

        first video will give you wants needed.

  32. The VBA code will merge data into one from multiple workbooks.

  33. The VBA Macro does not merge the data into one sheet. It only brings over sheets from other workbooks.

    1. this is useless, copiying data from other workbook to this workbook , not into one sheet

      1. Maybe it was not useful for you, but just worked for my purpose.

    2. Hi Dave,

      Exactly :) This whole article is about merging multiple Excel files into one, i.e. copying sheets from multiple workbooks into one workbook.

      If you are looking to merge data from multiple sheets into one sheet, you can try this VBA code or our Copy Sheets tool.

      1. Hi Svetlana,
        My requirement is quite similar to Dave's. So i went to the link provided by you above, But even that VBA code does not consolidate the data into one sheet, but only creates different sheets in the master sheet. Can you please help me?

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)