KutoolsforOffice — One Suite. Five Tools. Get More Done.

Easily Merge Two Tables Based on Multiple Key Columns in Excel

AuthorSiluviaLast modified

When merging two tables, a single lookup column may not be enough to identify matching records accurately. Using multiple key columns allows you to match the complete combination of values and return the correct corresponding data.

The VLOOKUP to merge two tables based on multiple key columns formula in Formula Helper Plus matches two values against their corresponding columns in another table and returns a value from the specified column. This makes it easier to merge related data without creating a helper column or manually writing a complex multiple-criteria lookup formula.


Advantages of Merging Tables Based on Multiple Key Columns

Matching multiple key columns helps distinguish records that cannot be identified accurately by one field alone. It is particularly useful for order details, inventory records, attendance lists, course registrations, and other datasets in which values repeat across individual columns.

Its main advantages include:

  • More accurate matching Evaluate two key values together to identify the correct corresponding record.
  • Easy cross-table data merging Bring related information from one table into another based on matching key values.
  • Flexible table organization Keep the source and destination tables on separate worksheets without rearranging their structure.
  • Simplified formula creation Generate the required multiple-criteria lookup formula from the selected values and ranges.
  • Dynamic results Automatically recalculate returned values when the referenced key values or source data change.

How to Merge Two Tables Based on Multiple Key Columns in Excel

This section explains how to merge two tables by matching two key columns and returning the corresponding data.

Before getting started, review the two worksheets used in this example:

  • The Order Details worksheet contains the records to be completed.
    a screenshot of the order details table
  • The Price Lookup worksheet contains the source data and the values to be returned.
    a screenshot of the lookup table

In the Price Lookup worksheet, ORD-1001 matches multiple rows, so Order ID alone cannot determine which unit price belongs to the first record in the Order Details worksheet. Matching it together with Product ID P-101 identifies the correct row and returns a Unit Price of $25.00.

Follow the steps below to return the correct unit price based on both key values.

Step 1: Select the First Output Cell

Begin by selecting the cell where you want the first returned value to appear.

In this example, select cell D7 in the Order Details worksheet, which is the first result cell in the Unit Price column.

Step 2: Open Formula Helper Plus

Select Kutools > Formula Helper > Formula Helper Plus.

a screenshot of opening the formula helper plus

Step 3: Find the Multiple-Key Lookup Formula

In the Formula Helper Plus dialog box:

  1. Switch to the Online tab.
  2. Select Lookup from the Category list.
  3. Select VLOOKUP to merge two tables based on multiple key columns from the Formula list.
    Alternatively, enter a keyword in the search box to locate the formula more quickly.
    a screenshot of opening the formula

Step 4: Configure the Lookup Arguments

The formula requires the complete lookup table, two lookup values, their corresponding key columns, and the number of the column containing the value to return.

Configure the arguments as follows:

  1. In the Lookup_table_Abs box, select the complete lookup table on the Price Lookup worksheet.
  2. In the Lookup_value1 box, select the first key value in the row where you want to return the result.
  3. In the Lookup_range1_Abs box, select the column within the lookup table that contains the values to be matched against Lookup_value1. In this example, select the Order ID column on the Price Lookup worksheet.
  4. In the Lookup_value2 box, select the second key value in the same row.
  5. In the Lookup_range2_Abs box, select the column within the lookup table that contains the values to be matched against Lookup_value2. In this example, select the Product ID column on the Price Lookup worksheet.
  6. In the Return_column_number box, enter the relative position of the column containing the value to return. In this example, enter 3 because Unit Price is the third column in the lookup table.
  7. Click OK.
    a screenshot of configuring the arguments

Step 5: Fill the Formula Down

Kutools inserts the generated formula into the selected cell and returns the Unit Price. To return prices for the remaining order items, select the result cell and drag its fill handle down.

a screenshot of filling the cells with formulas

Result

After the formula is filled down, the Unit Price column in the Order Details worksheet is completed. For each row, the formula finds the record in the Price Lookup worksheet where both the Order ID and Product ID match, and then returns the corresponding Unit Price.

For example, the combination of ORD-1001 and P-101 matches the first highlighted row in the lookup table, so $25.00 is returned. The other prices are returned in the same way using their respective Order ID–Product ID combinations.

a screenshot showing the results

Tips for Matching Multiple Key Columns

Accurate results depend on selecting the correct lookup values and keeping all referenced ranges properly aligned. The following tips can help prevent missing or incorrect matches.

  1. 1Select the complete lookup table. Lookup_table_Abs must include both key columns and the column containing the value to return.
  2. 2Keep the lookup ranges aligned. Lookup_range1_Abs and Lookup_range2_Abs must cover the same rows and contain the same number of cells.
  3. 3Select both lookup values from the same row. The two lookup values must belong to the same record in the destination table.
  4. 4Enter the correct return column number. Count the return column from the left edge of Lookup_table_Abs, rather than using its worksheet column number.
  5. 5Check the key values and combinations. Remove unnecessary spaces and keep identifiers consistently formatted. Each key combination should ideally identify only one source row; otherwise, the formula returns the first matching result.

FAQ – Frequently Asked Questions

The following questions address common situations that may arise when using multiple key columns to merge tables.

Do the two key columns need to be next to each other?

No. The two lookup ranges do not have to be adjacent, but they must cover the same rows and align correctly with Lookup_table_Abs.

Can I return data from a different column in the lookup table?

Yes. Change Return_column_number to the relative position of the required column within Lookup_table_Abs. For example, enter 4 instead of 3 to return Status rather than Unit Price.

What happens if the same key combination appears more than once?

The formula returns the value from the first matching row. If each combination should represent only one record, check the lookup table for duplicate combinations.

What happens if no matching combination is found?

The generated formula may return an #N/A error when no row in the lookup table matches both key values. Check the identifiers, extra spaces, data types, and selected ranges.

Will the results update when the lookup table changes?

Yes. The results recalculate when values within the referenced ranges change. However, records added outside those ranges are not included until Lookup_table_Abs and both lookup ranges are expanded.


Conclusion

Merging tables based on multiple key columns is useful when a record cannot be identified accurately by one field alone. In this example, matching Order ID and Product ID together allows the correct Unit Price to be returned from the Price Lookup worksheet for every row in Order Details.

This allows you to merge corresponding information from two tables without creating a helper column or manually constructing a complex formula.


Best Office Productivity Tools

🤖Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |  Round without Formula ...
Super Lookup: Multiple Criteria VLookup  |   Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |  Big Formula Bar   |  Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells   |  Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

ExcelWordOutlookTabsPowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in