[英]Excel formula to search two columns for unique value in one column and fixed value in another
Got status codes in column H (BE, BK, TR, MO) and Serial numbers in column N. My aim is to find rows with duplicate Serial numbers, and mark them out With "unik" on 1 of them and "duplikate" on similar cells/rows BUT at the same time do this only when status codes in H is either "BK" or "BE". 在H列中获得状态代码(BE,BK,TR,MO),在N列中获得序列号。我的目的是查找具有重复序列号的行,并在其中之一上标有“ unik”,并在其中标上“ duplikate”仅当H中的状态代码为“ BK”或“ BE”时,类似的单元格/行BUT才能同时执行此操作。
This is my attempt so far: 到目前为止,这是我的尝试:
=IF(AND((COUNTIF($N$2:$N132,$N132)=1)+0,OR($H$2:$H132="BK",$H$2:$H132="BE")),"bk-be_unik","bk-be_duplikat")
It Works, but only when status code "BE" or "BK" is found at the first row holding a duplicate Serial number. 它有效,但是仅当在第一行找到具有重复序列号的状态代码“ BE”或“ BK”时才有效。 If there are 6 rows holding Serial number "999", and the first row is status code like "MO", the formula give me "duplicate" on all 6 rows.
如果有6行的序列号为“ 999”,并且第一行是状态代码,如“ MO”,则该公式在所有6行中都给我“重复”的信息。
Is there a way to do this so that it will work no matter where the status code I'm searching for is located? 有没有办法做到这一点,无论我要搜索的状态代码在哪里,它都可以工作?
Here is one way of doing this 这是一种方法
In A2
use formula: 在
A2
使用公式:
=IF(SUM(COUNTIFS($N$2:$N$4000,N2,$H$2:$H$4000,{"BK","BE"}))>1,IF(SUM(COUNTIFS($N$2:$N2,N2,$H$2:$H2,{"BK","BE"}))=1,"unik","duplikate"),"")
Reversed order: 倒序:
=IF(SUM(COUNTIFS($N$2:$N$4000,N2,$H$2:$H$4000,{"BK","BE"}))>1,IF(SUM(COUNTIFS($N2:$N$4000,N2,$H2:$H$4000,{"BK","BE"}))=1,"unik","duplikate"),"")
当“ BK”或“ BE”在H列的同一行中时,请尝试使用此方法匹配N列中的序列号。
=IF(sumproduct(COUNTIFs($N$2:$N132, $N132, $H$2:$H132, {"BK", "BE"}))=1, "bk-be_unik", "bk-be_duplikat")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.