简体   繁体   English

Excel公式,用于匹配2列中的多个日期,返回“是”或“否”

[英]Excel formula to match multiple dates across 2 columns, returning Yes or No

I need a formula that will match dates across column A and B in the below table. 我需要一个公式,它将匹配下表中A列和B列的日期。 There are over 100000 results to match in each of my tables. 我的每个表都有超过100000个结果匹配。

If specific date appears in both columns, then it returns with 'Yes' statement. 如果两列中都显示特定日期,则返回“是”语句。 If it only appears in one column, than 'No'. 如果它只出现在一列中,而不是“否”。

在此输入图像描述

I tried to use the below formula but it doesn't return the correct output: 我尝试使用下面的公式,但它没有返回正确的输出:

=IF(COUNTIF($B:$B, $A:$A)=0, "Yes", "No")

The correct results should be as in column C. 正确的结果应如C列所示。

Thanks in advance. 提前致谢。

A Faster Excel Version 更快的Excel版本

Referring to the formula =IF(COUNTIF($A:$A,B2)=0,"No","Yes") 参考公式=IF(COUNTIF($A:$A,B2)=0,"No","Yes")

Looks like the same but its much faster. 看起来像是一样但速度要快得多。

=IF(ISERROR(MATCH(B1,$A:$A,0)),"No","Yes")

On first glance, match should be faster since it cannot count, but of course the reason is probably in the following logic: 乍一看,匹配应该更快,因为它不能计算,但当然原因可能是以下逻辑:
COUNT searches the whole range to calculate the COUNT and then the IF 'decides' if it is 0 or not. COUNT搜索整个范围以计算COUNT ,然后IF '决定'是否为0
MATCH searches the range only until it finds the MATCH and when found the IF 'decides via the ISERROR function' if it is TRUE or FALSE. MATCH仅搜索范围,直到找到MATCH,并且当发现IF '通过ISERROR函数决定'时它是否为TRUE或FALSE。 If the matches would be at the bottom of the range, maybe the speed gap could be disregarded, but they aren't. 如果匹配将在范围的底部,可能会忽略速度差距,但它们不是。

Rearranging the formulas like 重新安排公式

=IF(NOT(ISERROR(MATCH(B1,$A:$A,0))),"Yes","No")

or 要么

=IF(COUNTIF($A:$A,B2)<>0,"Yes","No")`

doesn't change a thing. 不会改变一件事。 MATCH still searches until a match is found, and COUNT still counts in the whole range. 匹配仍然搜索,直到找到匹配,并且COUNT仍然在整个范围内计数。

So to conclude: 总结如下:

MATCH is the ' Excel ' way to go. MATCH是' Excel '的方式。

This will do the trick, name what you want to display. 这将成功,命名你想要显示的内容。

The logic is this: It counts if the criteria exist in Column A. When no matches is found (=0) it give "Don't exist in Column A". 逻辑是这样的:如果条件A中存在标准则计数。当没有找到匹配(= 0)时,它给出“在A列中不存在”。

=IF(COUNTIF($A:$A,B2)=0, "Don't exist in Column A","Yes")

So in your case when we apply the formula it will look like this: 因此,在您应用公式的情况下,它将如下所示:

=IF(COUNTIF($A:$A;B3)=0, "No", "Yes")

在此输入图像描述

Notice in the picture I use " ; " as delimiter since I have a Nordic Excel version. 在图片中注意我使用“ ; ”作为分隔符,因为我有一个Nordic Excel版本。 US will probably use " , ". 美国可能会使用“ , ”。

If you need result when the Audit date column to match with date column and date column to match with Audit date then use 如果在审核日期列与日期列和日期列匹配时需要结果以与审核日期匹配,则使用

=if((countif(B:B,A2)+countif(A:A,B2))<>0,"Yes","No")

If you need result when Audit date match with the date column then use: 如果在审核日期日期列匹配时需要结果,请使用:

=if((countif(A:A,B2))<>0,"Yes","No")

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

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