当另一个值更改时,增加vlookup单元格引用

时间:2018-11-27 13:36:33

标签: excel vba excel-formula

所以我有一个vlookup,我只想在单元格旁边的值更改时增加单元格引用,例如:

源数据:

名称

Jane
John
Sally

目标表

索引名称

1 Jane
1 Jane
1 Jane
2 John
2 John
3 Sally
3 Sally
3 Sally

我想用以下方式填充目标表中的名称:

=IF(A1=A2,sourceA1,sourceA2)

sourceA2引用除外,仅在索引更改时递增。

希望如此!

2 个答案:

答案 0 :(得分:3)

如果这是您的Source工作表

enter image description here

这是您的Destination工作表

enter image description here

在您的Destination工作表的B列中使用此公式

=INDEX(Source!A:A;Destination!A:A + 1)  'Added +1 because of the header

获得以下结果

enter image description here

答案 1 :(得分:1)

根据您的示例,以下公式将起作用:
=INDEX(names,A1,)

假设names是源数据的定义名称。您当然也可以在此处输入相应的范围,例如$D1$D3
INDEX将从范围(示例中的A1)中提取names中指定的行,并且由于只有一列,因此您无需指定该列,因此我将此留空了,但是您也可以放1