You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Excel中合并两组含同名首列但行数据不全重叠的列(批量操作)

Hey Khaled, let's tackle this Excel data merging problem efficiently—no tedious manual row-by-row work needed! Here's a step-by-step solution that'll get you the exact format you're looking for:

Step 1: Create a master list of unique keys

Since both datasets share a common first column, we first need a complete list of all unique values from that column:

  • Copy the shared column from both datasets into a new blank column (say, column G) in your sheet.
  • Select this combined column, then head to the Data tab > Remove Duplicates. This gives you a clean, unique list of all keys from both datasets—this will be the foundation of your merged table.
Step 2: Pull in corresponding values with formulas

Let's assume:

  • Dataset 1 is in columns A (shared key) and B (value column)
  • Dataset 2 is in columns D (shared key) and E (value column)
  • Your unique key list is in column G

Add two new columns next to G (H for Dataset 1 values, I for Dataset 2 values) and use these formulas:

  • For column H (fetching from Dataset 1):
    =IFERROR(VLOOKUP(G2, A:B, 2, FALSE), "")
  • For column I (fetching from Dataset 2):
    =IFERROR(VLOOKUP(G2, D:E, 2, FALSE), "")
  • Drag these formulas down to cover all rows in your unique key list. The IFERROR function ensures that if a key doesn't exist in one dataset, it leaves a blank instead of an error message.
Step 3: Format to match your desired output
  • Rename your columns to something clear (e.g., "Shared Key", "Dataset 1 Value", "Dataset 2 Value")
  • Apply any formatting like cell borders or text alignment to mirror the example in your figure.
Bonus: Power Query for extra-large datasets

If you're dealing with thousands of rows, Power Query is a more robust, formula-free option:

  • Select Dataset 1, go to Data tab > From Table/Range (ensure your data has headers)
  • Repeat for Dataset 2 to load both into the Power Query Editor
  • In the editor, click Home > Merge Queries > Merge Queries as New
  • Choose the shared key column from both tables, select Full Outer Join (this preserves all rows from both datasets)
  • Expand the merged column to bring in the value column from Dataset 2, then replace null values with blanks
  • Load the merged table back into your Excel sheet—this will give you the exact combined format you need.

内容的提问来源于stack exchange,提问作者Khaled

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:36:33