简体   繁体   English

使用 VLOOKUP 和 IMPORTRANGE 查找匹配项并返回两个潜在值之一

[英]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.

相关问题 IF(VLOOKUP) vs INDEX(MATCH) 根据多个条件查找值 - IF(VLOOKUP) vs INDEX(MATCH) to find values based on multiple criteria VBA Vlookup /匹配键返回值 - VBA Vlookup/Match Keys return Value 通过两个条件在 R 中查找匹配值,一个是时间范围内的日期 - Find match values in R by two conditions, one being a date within a time range 匹配两列并根据其他两列中的条件返回值 - Match two columns and return values based on a condition in two other columns 返回两个变量R之一缺少的值 - Return values that are missing in one of the two variables R 使用带有 IF 语句的 VLOOKUP 来搜索范围并返回描述 - Using VLOOKUP with an IF statement to search a range and return description Excel-如何在表中查找两个值并在两个值匹配时返回另一个值 - Excel - how to look up a table for two values and return another value if these two values match 在 VBA 中使用 VLOOKUP - 通过引用不同的 VLOOKUP 或 INDEX/MATCH 来处理 N/A - Using a VLOOKUP in VBA - Taking Care of N/A's by referencing a different VLOOKUP or INDEX/MATCH 警告if语句使用R中的match查找和替换值 - warning on if statement to find and replace values using match in R 如果满足两个条件,则返回字符串-一个条件为匹配,而另一个条件为空 - Return string if two conditions are met - one being match and one being null in same row
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM