0

Is it possible to lookup values in excel in the following method:

Table 1

ID    |     Code
-----------------
1     |      I
1     |      J
1     |      K
2     |      I
2     |      J
2     |      L

Table 2

ID    |    I      |    J    |    K    |    L    
----------------------------------------------
1     |   14.40   |  12.33  |  9.21   |  
2     |   13.99   |  11.28  |         |   32.33

The lookup would be to add the column values in table 2 next to the table 'code' in table 1. So table 1 would change to:

Table 1

ID    |  Code  |  Amount
-------------------------
1     |   I    |   14.40
1     |   J    |   12.33
1     |   K    |   9.21 
1     |   L    |   
2     |   I    |   13.99
2     |   J    |   11.28
2     |   K    |   
2     |   L    |   32.33

As a reminder, this is a project being run in Microsoft Excel 2003.

Update

I believe I can use a vlookup on the first column and given I know the placement of the code fields, I could go this route but the issue would be I cannot copy and paste this formula across an entire column because the order of which codes may appear can vary (and are not the same from ID to ID).

4

2 回答 2

2

您可以使用索引和匹配

=INDEX($C$4:$E$6,MATCH(H3,$B$4:$B$6,0),MATCH(I3,$C$3:$E$3,0))

匹配在表 2 的行和列标题中查找您的 ID 和代码的位置。索引使用这些来返回行和列的交集。

于 2011-10-04T17:02:03.933 回答
0

假设表 1 在单元格 A1:B7 中,表 2 在 A10:E12 中,您可以将此公式放入 c2 并将其复制到 c7。这是一个数组公式,所以输入后需要按ctrl-shift-enter。

=SUM(IF($A$11:$A$12=A2,IF($B$10:$E$10=B2,$B$11:$E$12,0)))
于 2011-10-04T16:50:25.933 回答