您的请求可以通过一个简单的VLOOKUP
函数来处理:
步骤 1:在 Sheet2 中,复制 C 列(又名“Chan”列)并将其放在工作表的开头。现在您的 Sheet2 数据应该看起来像
Chan ttc event
30 XYZ L
40 XYZ L
6 XYZ L
Step2:在Sheet1中,在Sheet1的末尾添加一列(应该是F列)并将其命名为“ttc”(因为这是您要从Sheet2中查找的内容”。现在您的Sheet1数据应该如下所示
Date ID Other Sub Chan ttc
10000 100 Repeat X 30
10000 101 Repeat X 40
Step3:在Sheet1的F栏输入如下函数
=VLOOKUP(E2,Sheet2!$A$2:$C$4,2,)
输入此公式后,结果将立即出现
Explanation: the Excel Vlookup function takes the following four arguments, which are
separated with a comma:
1st argument is the cell (E2) containing the value in Sheet 1 to look for
2nd argument contains the range of data to look into (which resides in Sheet2 and the
cell range A2 through C4 is where the data resides.
NOTE1: the VLOOKUP function requires the 1st column of Sheet2 to be the column
to look into
NOTE2: we don't need to include the 1st row containing the header
NOTE3: the dollar signs represent absolute cell range so that when you copy it
down to other rows below them, they don't change (i.e., your data range
in Sheet2 is always the same
3rd argument represents the column # in Sheet2 to return if there's a match.
NOTE: column 1 starts with column A of Sheet2
4th argument is left blank
第 4 步:将此公式复制到 F 列下面的所有其他行注意:后续行应具有公式
=VLOOKUP(F2,Sheet2!$A$2:$C$4,2,)
=VLOOKUP(G2,Sheet2!$A$2:$C$4,2,) if you have 3 rows in Sheet1
=VLOOKUP(H2,Sheet2!$A$2:$C$4,2,) if you have 4 rows in Sheet1
ETC...