在表上匹配三个值(三个单元格) [英] Matching three values (three cells) on a table

查看:153
本文介绍了在表上匹配三个值(三个单元格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何用excel(如果可以完成)可以做到这一点?
如您所见,图像,我有一个值列表(在这种情况下为三个单元格),以在数据表的列表中查找和匹配,并且如果存在值,则为1,0表示在以下列中输出。所以基本上而不是单个单元格中的一个值,我想要搜索和匹配表上三个单元格中的三个值。 (注意:如果您注意到,值可能不会出现在表格上的每个相邻单元格中)。



***组值应在同一行上给出肯定的输出1。





------在下面的解决方案之后编辑----

  =  - (MAX((IF(MMULT((A2 = $ F $ 2:$ I $ 6)* 1,{1; 1; 1; 1}),1,))+(IF (MMULT((B2 = $ F $ 2:$ I $ 6)* 1,{1; 1; 1; 1}),1,))+(IF(MMULT((C2 = $ F $ 2:$ I $ 6)* 1,{1; 1; 1; 1}),1,)))> = COUNTA(A2:C2))

使用CTRL + SHIFT + ENTER确认



您可以使用TRANSPOSE(COLUMN($ F $ 2: $ I $ 2)^ 0)。 IF和TRANSPOSE使CTRL + SHIFT + ENTER成为必需。

解决方案

使用以下作为示例布局...



...其中范围 F2:H4 包含查找数组,列 A,B,C 包含您要查找的值,列 D 包含结果,您可以在单元格 D2中使用以下公式然后可以将其复制到下面的行...

  = IF(IF(COUNTIF($ F $ 2:$ H $ 4,=& A2)> 0,1,0)+ IF(COUNTIF($ F $ 2:$ H $ 4,=& B2)> 0,1,0)+ IF(COUNTIF $ F $ 2:$ H $ 4,=& C2)> 0,1,0)= 3,1,0)

检查 IF(COUNTIF($ F $ 2:$ H $ 4,=& A2)> 0,1,0) COUNTIF 表达式计算您要查找的所有值的出现次数(在这种情况下为 A2 ),然后 IF 表达式转换任何cou nt> 1到1.当您在所有三列中应用此方案时,如果嵌套的 IF 语句的总和为3,那么我们有三个匹配...一个你查看的每个值。






在你的情况下,D2的公式将是...

  = IF(IF(COUNTIF($ F $ 2:$ I $ 6,=& A2)> 0,1,0)+ IF(COUNTIF($ F $ 2:$ I $ 6,=& B2)> 0,1,0)+ IF(COUNTIF($ F $ 2:$ I $ 6,=& C2)> 0 ,1,0)= 3,1,0)






As @Grade'Eh'Bacon提到,这是一个更清洁的公式...

  = MIN(1,COUNTIF ($ F $ 2:$ I $ 6,A2),COUNTIF($ F $ 2:$ I $ 6,B2),COUNTIF($ F $ 2:$ I $ 6,C2))
/ pre>





I would like to know how this can be done with excel(if it can be done)? As you can see in the image, I have a list of values (three cells in this case) to find and match in a list of data table, and if the values are present, 1 for yes and 0 for no output in the following column. So basically instead of one value in a single cell, I want to search and match three values in three cells on a table. (note:if you noticed, the values may not be present in adjacent cells on the table every time).

*** Groups of values should be on the same row to give a positive output of 1.

------Edited after the solution below----

=--(MAX((IF(MMULT((A2=$F$2:$I$6)*1,{1;1;1;1}),1,))+(IF(MMULT((B2=$F$2:$I$6)*1,{1;1;1;1}),1,))+(IF(MMULT((C2=$F$2:$I$6)*1,{1 ;1;1;1}),1,)))>=COUNTA(A2:C2))

Confirmed with CTRL+SHIFT+ENTER

You can replace {1;1;1;1} with TRANSPOSE(COLUMN($F$2:$I$2)^0). The IF and TRANSPOSE make the CTRL+SHIFT+ENTER necessary.

解决方案

Using the following as an example layout ...

... where range F2:H4 contains your lookup array, columns A,B,C contain the values you are looking for, and column D contains the result, you can use the following formula in cell D2 which can then be copied down to the rows below ...

=IF(IF(COUNTIF($F$2:$H$4,"="&A2) >0,1,0) + IF(COUNTIF($F$2:$H$4,"="&B2) >0,1,0) + IF(COUNTIF($F$2:$H$4,"="&C2) >0,1,0) = 3,1,0)

Examining IF(COUNTIF($F$2:$H$4,"="&A2) >0,1,0), the COUNTIF expression counts all the occurrences of the value you are looking for (A2 in this case), and then the IF expression converts any count > 1 to 1. When you apply this scheme across all three columns, if the sum of the nested IF statements is 3, then we have three matches ... one for each value you looked up.


In your case, the formula for D2 would be ...

=IF(IF(COUNTIF($F$2:$I$6,"="&A2) >0,1,0) + IF(COUNTIF($F$2:$I$6,"="&B2) >0,1,0) + IF(COUNTIF($F$2:$I$6,"="&C2) >0,1,0) = 3,1,0)


As @Grade 'Eh' Bacon mentions, this is a much cleaner formula ...

=MIN(1,COUNTIF($F$2:$I$6,A2),COUNTIF($F$2:$I$6,B2),COUNTIF($F$2:$I$6,C2))


这篇关于在表上匹配三个值(三个单元格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆