Accessing data from multiple Excel files can be time-consuming and hard.
You often have to switch between multiple open windows, it’s messy and you feel like there’s data all over the place.
So, when you have to access data that is spread out over multiple Excel files, it makes sense to merge the sheets from all these files into one single Excel workbook.
This keeps your data organized and saves a lot of referencing time.
In this tutorial, we show you three ways to merge two Excel files:
Table of Contents
Imagine you have two separate files:
These two files contain order-related information (for an imaginary company).
File1 has 2 tabs (named Apr-Jun 2021 and Jul-Sep 2021) and File2 has a single tab (named Jan-Mar 2021).
Let’s say you want to merge File1 and File2 by bringing both sheets of File1 into File2.
As mentioned before, there are 3 ways to do this. The method you choose will depend on your requirement and how your data is structured.
Let us look at each method one by one.
This is the simplest and the most commonly used method to merge two Excel Files.
This method is suited in situations where you have to merge two or more Excel files that have only a few sheets, and you need to do it only once in a while.
Below are the merge two Excel files manually:
All sheets of File1 should now get copied to File2, so that it now contains 3 sheets in all.
Note that for this method to work, you need to have both the files open (one from which you want to copy the sheets and the one where you want to copy these sheets).
Also, note that this method will create a copy of sheets in File1 and add these to File2. These sheets will still remain in File1.
As I mentioned, this method is fine if you want to do this once in a while with files that have less number of sheets. If you have more sheets, there is always a chance of human error. In such cases, you can use the VBA or the Power Query method covered next.
In case you have more than two Excel files that you want to merge, you can follow the same process, where you combine two Excel files, and then combine the third/fourth file with it.
The second method to merge two Excel files uses the following VBA script:
'Code by Steve Scott from https://spreadsheetplanet.com Sub MergeSheets() Dim SourceWb As Workbook Dim TargetWb As Workbook Set SourceWb = Workbooks("File1") Set TargetWb = Workbooks("File2") Dim SourceSheet As Worksheet For Each SourceSheet In SourceWb.Sheets SourceSheet.Copy After:=TargetWb.Sheets(TargetWb.Sheets.Count) Next End Sub
The above script simply takes two files, “File1” and “File2“, cycles through each sheet of File1 and appends a copy of it to File2.
All you need to do is replace the filenames “File1” and “File2” in the above code with your required source and target files.
For this code to work, your Excel files need to be open. In case you want the code to open a closed file, copy sheets from one file to another, and then close the files again, you can do that too (you will need to modify the code to do that).
Note: This script copies the “File1” sheets and pastes them into “File2”. This means the original sheets within “File1” remain as they were.
To run the above script, follow the steps below:
You should now find the sheets of File1 and File2 merged into File2, while retaining a copy of the original sheets in File1 too.
Note: If you cannot find the Developer menu option, navigate to File->Options->Customize Ribbon and check the Developer option. Click OK.
If you’re using Excel 2016 or newer versions, you can also use the Get & Transform tool to merge two or more Excel files.
The Get & Transform tool is a Power Query feature that allows you to import data from multiple sources quickly and easily.
The great thing is that you can use it to make changes to your source data as required before importing it to the new workbook.
Here are the steps that you need to follow in order to merge two Excel Files using the Get & Transform tool:
You should now see two new sheets in File2.
Notice that the names of the sheets are just the generic Sheet1 and Sheet2, so you’ll have to double click on each tab and change the sheet names (if you need to).
That’s it! You have now merged File1 into File2, which now contains all 3 sheets!
Also, notice that the data in the newly imported sheets are in the form of an Excel table. If you don’t want that, you could simply convert them back to ranges by navigating to Table Design->Convert to Range.
When you are asked to confirm, simply click OK.
In this tutorial, we showed you 3 ways to merge two files in Excel.
The first two methods (using Move or Copy and using VBA) are more commonly used since they have been around for a while.
The last method (using Get & Transform) is the lesser-used method since it is fairly new and only available in newer Excel versions.
However, Power Query is increasingly becoming the go-to tool for businesses and other industries, so it makes sense to learn how to bring together data from multiple sources into the framework, to facilitate further processing.
Other articles you may also like:
I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.