In this tutorial, you will find some tricks on merging Excel tables by matching data in one or more columns as well as combining worksheets based on column headers.
When analyzing data in Excel, how often do you have all necessary information gathered in a single worksheet? Almost never! It is a very common situation when different pieces of data are dispersed across many worksheets and workbooks. Fortunately, there are a few different ways to combine data from multiple tables into one, and this tutorial will teach you how to do this quickly and effectively.
Whatever task you need to perform in your worksheets, where do you look for a solution in the first place? Like many users, I usually go to the Formulas tab and open a list of functions. Merging tables is no exception :)
If you are to merge two tables based on one column, VLOOKUP is the right function to use.
Supposing you have two tables in two different sheets: the main table contains the seller names and products, and the lookup table contains the names and amounts. You want to combine these two tables by matching data in the Seller column:
As you see, the order of the names in the main table does not correspond with that in the lookup table, therefore a simple copy/pasting technique won't work.
To combine two tables by a matching column (Seller), you enter this formula in C2 in the main table:
=VLOOKUP($A2,'Lookup table'!$A$2:$B$10,2,FALSE)
Where:
Copy the formula down the column, and you will get a merged table consisting of the main table, plus the matched data pulled from the lookup table:
Please be aware that Excel VLOOKUP has several limitations, the most critical of which are 1) inability to pull data from a column to the left of the lookup column and 2) a hardcoded column number breaks a formula when you add or remove columns in the lookup table. On the bright side, you can easily reorder the returned columns simply by changing the number in the col_index_num argument.
If you are looking for a more powerful and versatile alternative to the VLOOKUP function, embrace this INDEX MATCH combination:
The syntax is explained in detail in this tutorial: INDEX / MATCH in Excel. And here I will show you how to use this formula to look up from right to left, something that VLOOKUP is unable to do.
Let's say you have another lookup table with order IDs in the first column and you wish to copy those IDs to the main table by matching the seller names. For better visualization, both tables are put on the same sheet:
To accomplish the task, you supply the following arguments to the Index Match formula:
Please notice the $ sign that locks the ranges to prevent them from changing as you copy the formula down the table:
The completed formula looks as follows:
=INDEX($E$2:$E$10, MATCH($A2, $F$2:$F$10, 0))
…and combines data from two tables perfectly:
In Excel 365, you can use the new XLOOKUP function for the same purpose:
=XLOOKUP(A2, $F$2:$F$10, $E$2:$E$10, "Not found")
If the two tables you wish to join do not have a unique identifier, such as an order id or SKU, you can match values in two or more columns by using this formula:
The formula's breakdown can be found here: Look up with multiple criteria. For now, let's focus on the practical usage.
Assuming you have the following two tables to be combined into one. Because the Order ID column is missing in the lookup table, the only way to match the orders is by Seller and Product:
Based on the above screenshot, let's define the arguments for our formula:
Again, be sure to fix all the ranges with absolute cell references so that they won't change when you copy the formula down:
=INDEX($F$2:$H$9, MATCH(1, ($B2=$F$2:$F$9) * ($C2=$G$2:$G$9), 0), 3)
Enter the formula in D3, press Ctrl + Shift + Enter, copy it to the below rows and check the result:
To have a closer look at the above examples and probably reverse-engineer the formulas, you are welcome to download our sample workbook to Merge Two Tables in Excel.
In situations when you need to combine two or more tables with different numbers of rows and columns, Excel Power Query may come in handy. However, please be aware that joining tables with Power Query cannot be done with a mere couple of clicks. Explaining all the nuances would take far more space than we have here, so I will just briefly outline the main features:
The detailed guidance can be found in this tutorial: How to join tables with Excel Power Query.
If you are not very comfortable with Excel formulas yet, nor do you have time to figure out the arcane quirks of Power Query, our Merge Tables Wizard could be your time-saver. Below I will show three most popular uses cases.
If you find the array formula for columns match hard to remember, rely on our add-in to do the job quickly and perfectly.
For this example, we will be using the already familiar tables and join them based on 2 columns, Seller and Product. Please note that the lookup table has 2 more columns than the main table:
With the Merge Tables Wizard added to your Excel ribbon, here's what you need to do:
The default options work just fine in our case, so we click Finish without changing anything:
Allow the wizard a few seconds for processing and review the result:
As you can see in the screenshot above, the wizard has done the following:
In case your main table contains some outdated data, you can have it updated with the corresponding values from the lookup table.
As an example, let's merge 2 tables by Order ID and update the values in the Price column:
To get the result shown in the above image, this is what you need to do:
Step 1. Select the main table.
Step 2. Select the lookup table.
Step 3. Choose Order ID as the matching column.
Step 4. Select Price as the column to update.
Step 5. Skip it because there are no columns to add.
Step 6. Since there are a few gaps in the New price column, we choose to update only if cells in the lookup table contain data. Optionally, you can highlight the updated cells with any color of your choosing. The screenshot below shows the settings:
In situations when a lookup table contains several occurrences on the lookup value, you may want to pull them all to your main table. The task can be accomplished with one of the non-trivial array formulas described in Vlookup to return multiple matches in Excel. Or you can do it the easy way with the Merge Tables Wizard.
Supposing your main table contains just one order of each seller, and the lookup table contains additional orders. Now you want to combine all the orders in one table, grouped by seller name like this:
Looks like a lot of work to do? Not if you have the Merge Tables Wizard at your disposal :)
Step 1. Select the main table.
Step 2. Select the lookup table.
Step 3. Choose Seller as the column to match.
Step 4. Update Order ID and Product.
Step 5. There are no columns to add.
Step 6. Insert additional matching rows after the row with the same key value. Optionally, set a background color for added rows to review the changes with a quick glance:
The above examples show just 3 of many possible ways to join tables in Excel. If you are curious to see other scenarios that the Merge Table Wizards can handle, please check out the visuals on this page. Or you can download a 30-day trial version and give it a shot.
In the above examples, we were merging two tables that have identical columns and pulling data from one table to another. In case you want to join multiple tables from different sheets into one based on columns headers, our Combine Sheets add-in is the right tool for the job.
The below image shows the source tables and desired result:
And here's how you can accomplish the task:
If you'd like to combine just one table, not all data, hover over the sheet's name, and then click the Collapse dialog icon on the right to select a range:
Done! The three tables are combined into one exactly like shown in the beginning of this example.
The Merge Tables Wizard and Combine Sheets are the most popular tools to join tables in Excel. If you have some other task in mind, chances are that you will also find a quick solution on the Ablebits Data tab:
Let me briefly describe what each of these add-ins does:
Merge Two Tables - joins two tables that have one or more identical columns, as shown in these examples.
Combine Sheets - merges multiple worksheets into one based on column headers, like we did a moment ago in this example.
Merge Duplicates - combines duplicate rows by key columns.
Consolidate Sheets - joins tables together and summarizes their data.
Copy Sheets - provides 4 different ways to merge sheets in Excel.
Merge Cells - merge cells, columns, and rows without losing data, even if a selection contains multiple values.
Vlookup Wizard - quick way to build a Vlookup or Index/Match formula best suited for your data set.
Compare Sheets - find, highlight, and merge differences between two worksheets.
Compare Multiple Sheets - highlight differences in two or more sheets.
All the above features are included with our Ultimate Suite for Excel as well as 60+ other tools. An evaluation version for Excel 2019, 2016, 2013 and 2010 is available here. I thank you for reading and hope to see you on our blog next week!
17 responses to "How to merge two or more tables in Excel"
Hi Svetlana,
I read your posts with interest. I hope you can help me with my query:
I have three one-column tables and wish to create a new 3-column table combining them in the following way:
TableA:
Item_A1
Item_A2
Item_A3
TableB:
Item_B1
Item_B2
TableC:
Item_C1
Item_C2
Item_C3
Item_C4
NewTable:
Item_A1 Item_B1 Item_C1
Item_A1 Item_B1 Item_C2
Item_A1 Item_B1 Item_C3
Item_A1 Item_B1 Item_C4
Item_A1 Item_B2 Item_C1
Item_A1 Item_B2 Item_C2
Item_A1 Item_B2 Item_C3
Item_A1 Item_B2 Item_C4
Item_A2 Item_B1 Item_C1
Item_A2 Item_B1 Item_C2
Item_A2 Item_B1 Item_C3
Item_A2 Item_B1 Item_C4
Item_A2 Item_B2 Item_C1
Item_A2 Item_B2 Item_C2
Item_A2 Item_B2 Item_C3
Item_A2 Item_B2 Item_C4
Item_A3 Item_B1 Item_C1
Item_A3 Item_B1 Item_C2
Item_A3 Item_B1 Item_C3
Item_A3 Item_B1 Item_C4
Item_A3 Item_B2 Item_C1
Item_A3 Item_B2 Item_C2
Item_A3 Item_B2 Item_C3
Item_A3 Item_B2 Item_C4
Please note that the number of rows in each of the three tables are dynamic and populated from SQL server queries. So, a copy/paste method is not practical. I think Power Query is the best approach but I don't how.
I need to publish/send reports based on the new table. So, if your "Ultimate Suite" provides a solution for me, does it need to be installed on the remote computers too?
Many thanks for your help.
Abbas
Hi Abbas,
I regret to tell you that none of our tools can help with this task. I am not sure that even Power Query can do that, at least I don't know a way. Sorry :(
Hi Abbas did you figure out how to do this?
Hi,
I have a question. I just bought the add-in but I am unable to figure out what I want to do.
I have excel sheets for each projects I am working on.
Sheet Project A
Table1, Columns: Task, Assigned to, Start date, Due date, Status
Sheet Project B
Table2, Columns: Task, Assigned to, Start date, Due date, Status
Sheet Project C
Table3, Columns: Task, Assigned to, Start date, Due date, Status
And now I want to view all the tasks created in these three tables on 1 single table.
Could you tell me how to do it?
Best regards,
Baatarbat
~ Amazing Add-in! Thank you very much for still developing this very useful and resourceful tool, Keep it up! =)
tHANK YOU VERY MUCH
Hi,
I was wondering if it was possible to put the Merge Two Tables feature in a macro or VBA script? I have to do this process multiple times a month and I'd like to automate it.
hey there;
I have a question, is there any way to overlay tables like he following;
table 1;
monday tues wed thurs friday
10 m10 t10 w1o th10 fri10
11 m11 t11 w11 th11 fri11
12 m12 t12 w12 th12 fri12
13 m13 t13 w13 th13 fri13
table 2;
monday tues wed thurs friday
10 M10 T10 W1o TH10 FRI10
11 M11 T11 W11 TH11 FRI11
12 M12 T12 W12 TH12 FRI12
13 M13 T13 W13 TH13 FRI13
and get the resulting table:
monday tues wed thurs friday
10 m10 t10 w1o th10 fri10
M10 T10 W1o TH10 FRI10
11 m11 t11 w11 th11 fri11
M11 T11 W11 TH11 FRI11
12 m12 t12 w12 th12 fri12
M12 T12 W12 TH12 FRI12
13 m13 t13 w13 th13 fri13
M13 T13 W13 TH13 FRI13
Hello,
I have been trying to combine a couple of sheet with one common value, how would you combine this:
If Sheet1!A1 = Sheet2!B2 then combine Sheet2!C2:sheet2!I15
Thanks in advance!
I have two tables like with these records:
Table 1: Badge# | Name | EmployeeID
Table 2: EmployeeID | SchoolID | Name | Badge#
Is there any ways that I can get the badge# record from table1 to the badge# in table 2 with the matching EmployeeID.
Thank you.
Can you please update this guide to also include the steps to merge tables using the new XLOOKUP function as an alternative to VLOOKUP and INDEX/MATCH?
Hi Jason,
It's an excellent suggestion, thank you! I have added an XLOOKUP formula to the INDEX/MATCH example. As soon as I have a little more time, I will try to describe it in more detail.
In the meantime, you can take a look at our XLOOKUP tutorial that covers a lot of interesting use cases. Hopefully, you'll find the examples useful.
Is there a size limit to your combine tables add in? I’ve got a couple data tables with ~3,700 rows. I need to join 2 such tables each with about 10 columns. A numeric code is the common column between them.
I am a full noob !
I have suppliers who have given me tables with door models on the top row sizes down the left column and pricing to the right column under the door models
How do i combine these tables to read read :
Door model, door size, and door price so i can import these items into my catalogue.
I have searched everywere - in the past i have used concatenate but there must be an easier way to combine 20000 plus items a section at a time ? This information will be LIFE CHANGING to me, thanks in advance ! I am trying my best !
Hello George!
I hope you have studied the recommendations in the above tutorial. We have a tool that can solve your task in a couple of clicks: Ablebits Data - Merge Tables.
This tool is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and use for free: https://www.ablebits.com/files/get.php?addin=xl-suite&f=free-trial
Unfortunately, without seeing your data it is impossible to give you advice.
I'm sorry, it is not very clear what result you want to get. Could you please describe your task in more detail and send us a small sample workbook with the source data and expected result to support@ablebits.com? Please shorten your tables to 10-20 rows/columns and include the link to your blog comment.
We'll look into your task and try to help.
Dear Svetlana,
Thankyou for this it is very helpful. Could you guide me on the appropriate option for my below issue.
I have a file(ytd) that I need to update monthly, with monthly figures. So my file that needs to be updated has 3 columns with data, now to this data/figures I need to add the monthly figures and arrive at the the updated total figures ytd.
YTD file Column1 =5
MTD file Column1 =3
Updated YTD file Column1 =8
Please guide.
Hi Svetlana Cheusheva
I have six sheets that have purchases of six companies, the amount of data is huge one of these sheets has over 70000 rows of data. my goal is to extract the mutual purchases items only between these companies. is there any way to do this because I have tried many ways to do so but I haven't managed.
Thanks in advance for your time and effort