简体   繁体   English

如果'N / A'运行两个vlookup

[英]Run two vlookup if an 'N/A'

I am currently in the process of trying to create a vlookup function that will check cell A2 and check it on sheet1. 我目前正在尝试创建一个vlookup函数,它将检查单元格A2并在sheet1上检查它。 If it brings back an error, it should go to B2 and then check on sheet1 and bring back the results. 如果它带回错误,它应该转到B2然后检查sheet1并返回结果。

This is what i currently have: 这就是我目前拥有的:

=IF(ISNA(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE)),"0",VLOOKUP(B2,'Sheet1'!$A$2:$A$1932,1,FALSE))

But it doesn't seem to be bringing back all the results, it is bringing back some results from each list A2 and B2. 但它似乎没有带回所有结果,它带回了每个列表A2和B2的一些结果。

What am i doing wrong? 我究竟做错了什么?

Thanks in advance. 提前致谢。

Try using: 尝试使用:

=IF(ISNA(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE)),"0",VLOOKUP(A2,'Sheet1'!$A$2:$B$1932,2,FALSE))

Or you can use an IFERROR to make things shorter: 或者您可以使用IFERROR缩短时间:

=IFERROR(VLOOKUP(A2,'Sheet1'!$A$2:$B$1932,2,FALSE),"0")

(You can omit the quotes around 0 if you mean a numerical 0 as opposed to a text 0 ) (如果你的意思是数字0而不是文字0你可以省略0左右的引号)

This formula will get the value from column B in Sheet1 using the lookup value A2 from Sheet2 and looking it up in column A in Sheet1. 此公式将使用Sheet2中的查找值A2从Sheet1中的列B获取值,并在Sheet1中的列A中查找它。

VLOOKUP checks the value of A2 in column Sheet1!A:A and returns the value from column Sheet1!B:B with the formula: VLOOKUP检查Sheet1!A:ASheet1!A:A A2的值Sheet1!A:A并返回Sheet1!B:BSheet1!B:B的值,其公式如下:

=VLOOKUP(A2,'Sheet1'!$A$2:$B$1932,2,FALSE)
                           ^      ^
                           1      2
  1. B is the result column B是结果列

  2. 2 is in the index relative to A. A is column 1, B is column 2. 2是相对于A的索引.A是列1,B是列2。


EDIT: 编辑:

If you want to get the value from column A only, checking the value of A2 first and B2 on failure of the first, then you can use: 如果您只想从A列获取值,请先检查A2的值,然后检查第一个的失败,然后您可以使用:

=IFERROR(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE),VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE))

This should work: 这应该工作:

=IFERROR(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE),VLOOKUP(B2,'Sheet1'!$A$2:$A$1932,1,FALSE))

It will use A2 to and try and find it in sheet1 and if it returns an error, it will go B2 and find the item on sheet1. 它将使用A2并尝试在sheet1中找到它,如果它返回错误,它将转到B2并在sheet1上找到该项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM