如何在Excel中的同一工作表中使用VLookup

时间:2014-07-10 20:05:20

标签: excel vba vlookup

我有以下Excel数据:

    A          B           C
1 asdasd    asdasd     VLOOKUP("fg",$A$1:$A$11,2,FALSE)
2 asdasd    dfgd
3 asdasd    fghfgh
4 asdasd    tryrty
5 asdasd    456456
6 asdasd    45456
7 asdasd    456456
8 fgddgh    46fgtfgh
9 fghfgh    46456
10 dfgdfg   456546
11 fghfgh   456456

C列中,我收到#N/A

我希望实现的目标是,如果{A}列在A列中,请显示C列中B列的值。

我怎样才能做到这一点?

3 个答案:

答案 0 :(得分:1)

您需要使用if(iserror(vlookup()),"",vlookup())将vlookup括起来

所以

=如果(ISERROR(VLOOKUP(" FG",$ A $ 1:$ B $ 11,2,FALSE)),"",VLOOKUP(" FG&# 34;,$ A $ 1:$ B $ 11,2,FALSE))

基本上如果找不到fg,就会抛出错误。 if(iserror())表示如果出现错误,则返回空白单元格。如果没有错误(fg存在),则返回第2列。

在您当前的表格中,此功能将返回""对于所有行,因为它们都不是=" fg"。如果你想要任何包含的东西,你可以使用别人提到的外卡,但听起来你想要精确点击。

答案 1 :(得分:0)

你只需要改为

VLOOKUP("fg",$A$1:$B$11,2,FALSE)

答案 2 :(得分:0)

您得到#N/A,因为"fg"中的VLOOKUP正在搜索完全匹配(即“fg”),而且A列中没有。

而是使用通配符。例子:

=VLOOKUP("fg",A2:B11,2,FALSE) //gets exact match

=VLOOKUP("*fg",A2:B11,2,FALSE) //matches when `fg` at the end e.g. `aaaafg`

=VLOOKUP("fg*",A2:B11,2,FALSE) //matches when `fg` at the start e.g. `fgaaaa`

=VLOOKUP("*fg*",A2:B11,2,FALSE) //matches when `fg` found in the entry e.g. `aafgaa`