To achieve this in Excel without using a macro, you can use a combination of the INDEX and MATCH functions. Here’s a step-by-step guide:
Step 1: Prepare Your Data
Assume you have the following data:
- 2D Name Table: Located in
Sheet1 starting from cell A1.
- Name-Value Table: Located in
Sheet2 with names in column A and values in column B.
Step 2: Create the Third Table
-
Select the Cell for the First Value:
- Go to the cell where you want to start your third table (e.g.,
Sheet3!A1).
-
Enter the Formula:
- Use the following formula to look up the value corresponding to the name:
=IFERROR(INDEX(Sheet2!$B$2:$B$100, MATCH(Sheet1!A1, Sheet2!$A$2:$A$100, 0)), Sheet1!A1)
- Adjust the ranges (
$B$2:$B$100 and $A$2:$A$100) to fit your actual data.
Explanation:
MATCH(Sheet1!A1, Sheet2!$A$2:$A$100, 0): This finds the row number in the Name-Value table where the name in Sheet1!A1 matches.
INDEX(Sheet2!$B$2:$B$100, ...): This returns the value from the second column of the Name-Value table corresponding to the matched row.
IFERROR(..., Sheet1!A1): This handles cases where a name in the 2D table doesn’t have a corresponding value in the Name-Value table; it will simply return the original name.
Step 3: Copy the Formula
- Drag to Fill the Table:
- Drag the fill handle (small square at the bottom-right corner of the selected cell) across the rows and columns to fill the entire table.
Step 4: Convert Formulas to Values (Optional)
If you want to convert the formulas to static values:
- Select the Entire Table:
- Highlight the cells containing the formulas.
- Copy and Paste as Values:
- Press
Ctrl+C to copy the selected cells.
- Right-click on the selected area and choose
Paste Special -> Values.
This will replace the formulas with their calculated values, making the table static.
Example
Assume:
The resulting Third Table in Sheet3 will be:
A B C
1 10 20 30
2 40 50 60
This method allows you to dynamically replace names with their corresponding values without using a macro.