[英]Using VLOOKUP and IMPORTRANGE to find a match and return one of two potential values
I am trying to change the value of cell B1 depending on if cell A1's value is found in another spreadsheet.我试图根据是否在另一个电子表格中找到单元格 A1 的值来更改单元格 B1 的值。 If there is a match, I want the cell to say "banned".如果有匹配项,我希望单元格显示“禁止”。 If A1 isn't found in the other spreadsheet, I want it to say "active'.如果在另一个电子表格中找不到 A1,我希望它说“活动”。
I've been playing around with this我一直在玩这个
=if((VLOOKUP(A3,IMPORTRANGE(" https://docs.google.com/xyz ","ALL BANNED ACCOUNTS!$G$2:$G$300"),1,false))=A3,"Banned","Active") =if((VLOOKUP(A3,IMPORTRANGE(" https://docs.google.com/xyz ","ALL BANNED ACCOUNTS!$G$2:$G$300"),1,false))=A3,"Banned" ,"活动")
and can only get it to return "Banned".并且只能让它返回“禁止”。 If there is no match, it always returns #N/A.如果没有匹配项,它总是返回#N/A。
How can I remedy this?我该如何补救?
Thanks!谢谢!
Try changing "FALSE" TO "TRUE".尝试将“假”更改为“真”。 I have found that VLOOKUP behaves erratically, and simply changing the [is_sorted] value helps.我发现 VLOOKUP 行为不稳定,只需更改 [is_sorted] 值会有所帮助。
Also, this may or may not make a difference, but you have an extra set of parentheses in your formula:此外,这可能会也可能不会有所作为,但是您的公式中有一组额外的括号:
=if(VLOOKUP(A3,IMPORTRANGE("https://docs.google.com/xyz","ALL BANNED
ACCOUNTS!$G$2:$G$300"),1,false)=A3,"Banned","Active")
This is an old question, but in case it helps someone, since you are using VLOOKUP in one column, the only choices are that it equals A3, or that it isn't found, and if it isn't found, VLOOKUP fails, rather than equaling something else.这是一个老问题,但如果它对某人有帮助,因为您在一列中使用 VLOOKUP,唯一的选择是它等于 A3,或者找不到,如果找不到,VLOOKUP 失败,而不是等于其他东西。 Therefore, you can use this formula:因此,您可以使用以下公式:
=iferror(if(VLOOKUP(A3,IMPORTRANGE("https://docs.google.com/xyz","ALL BANNED
ACCOUNTS!$G$2:$G$300"),1,false)=A3,"Banned","irrelevant"),"Active")
Note that "irrelevant" can be changed to anything, ie 0, etc. This result will never happen, as if VLOOKUP isn't equal to the search cell (in this case, A3), it will throw an error.请注意,“无关”可以更改为任何内容,即 0 等。这种结果永远不会发生,就像 VLOOKUP 不等于搜索单元格(在本例中为 A3)一样,它会抛出错误。 So, "Active" as the result if there's an error will show rather than the value if VLOOKUP is false (since it can't be).因此,如果 VLOOKUP 为 false(因为它不可能),那么如果出现错误,结果将显示为“Active”而不是值。
Hopefully this helps someone!希望这对某人有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.