简体   繁体   English

查找包含4个特定值的所有行?

[英]Find all rows that contains 4 specific values?

I am using excel and I have a table of numbers with 6 columns from A to F and more than 1000 rows. 我正在使用excel,我有一个数字表,从A到F有6列,超过1000行。 For example, from my table, 例如,从我的表中,

4 17 37 38 47 53 4 17 37 38 47 53
8 43 54 55 56 60 8 43 54 55 56 60
4 18 21 25 38 57 4 18 21 25 38 57
15 25 37 38 58 59 15 25 37 38 58 59
4 16 19 20 27 43 4 16 19 20 27 43
18 32 47 50 54 56 18 32 47 50 54 56

i want to find if there is at least a row ( it must be a row! ) that contains the numbers 16 19 20 27. From this example, there is a match, but i don't know how to make a search or formula using four diferent numbers. 我想找到是否至少有一行( 它必须是一行! ),其中包含数字16 19 20 27.从这个例子中,有一个匹配,但我不知道如何进行搜索或公式使用四个不同的数字。

I feel like I need to use the match function but can't quite figure it out and I'm not sure about it. 我觉得我需要使用匹配功能,但不能完全理解它,我不确定。 Does anyone know how to do this? 有谁知道如何做到这一点?

Thanks! 谢谢!

This should work: 这应该工作:

=IF(AND(OR(A1=16,B1=16,C1=16,D1=16,E1=16,F1=16),OR(A1=19,B1=19,C1=19,D1=19,E1=19,F1=19),OR(A1=20,B1=20,C1=20,D1=20,E1=20,F1=20),OR(A1=27,B1=27,C1=27,D1=27,E1=27,F1=27)),"Yes","No")

Put it in a new column in the table. 将它放在表格的新列中。 It will return a Yes if the row contains all 4 values, and a No otherwise. 如果行包含所有4个值,则返回Yes ,否则返回No You can then filter the new column of Yes/No to search for a row with Yes 然后,您可以过滤“是/否”的新列以搜索带有“ Yes的行

I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F# . 我把你要寻找的四个值放在I1:L1和要在A1:F#搜索的数据数组。 Then in column G create a helper column that concatenates A:F into a delimited string. 然后在G列中创建一个辅助列,将A:F连接成一个分隔的字符串。 The formula in G1 is: G1的公式是:

=":"&A1&":"&B1&":"&C1&":"&D1&":"&E1&":"&F1&":"

where I've used ":" for the delimiter (you can use any char that's not in your data). 我使用“:”作为分隔符(你可以使用你数据中没有的任何字符)。

The result in G1 is: G1的结果是:

:4:17:37:38:47:53:

Now in H1 use this formula to search: 现在在H1使用此公式进行搜索:

=NOT(ISERR(FIND(":"&$I$1&":",G1)*FIND(":"&$J$1&":",G1)*FIND(":"&$K$1&":",G1)*FIND(":"&$L$1&":",G1)))

Each FIND will return an INT if the value (with leading and trailing delimiters) is found and #VALUE! 如果找到值(带有前导和尾随分隔符)并且#VALUE,则每个FIND将返回一个INT! otherwise. 除此以外。 So the product will be an INT if all values are found and #VALUE! 因此,如果找到所有值并且#VALUE,则该产品将是INT! otherwise. 除此以外。 Wrapping the FINDs inside an ISERR makes the result prettier (TRUE/FALSE instead of #VALUE!), and inverting with NOT returns TRUE when all 4 values are found and FALSE otherwise. FINDs包装在ISERR使得结果更漂亮(TRUE / FALSE而不是#VALUE!),并且当找到所有4个值时,使用NOT反转返回TRUE,否则返回FALSE。

Hope that helps. 希望有所帮助。

Here's another way --- more elegant (no helper column). 这是另一种方式---更优雅(没有辅助列)。 As before, I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F# . 和以前一样,我把你要寻找的四个值放在I1:L1和要在A1:F#搜索的数据数组。 Then in column G use this ARRAY formula (CTRL-SHIFT-ENTER): 然后在G列中使用此ARRAY公式(CTRL-SHIFT-ENTER):

=NOT(OR(PRODUCT(A1:F1-$I$1)<>0,PRODUCT(A1:F1-$J$1)<>0,PRODUCT(A1:F1-$K$1)<>0,PRODUCT(A1:F1-$L$1)<>0))

Each PRODUCT term checks for the existence of one value and returns 0 when the value is found and a non-zero value otherwise. 每个PRODUCT术语检查是否存在一个值,并在找到值时返回0 ,否则返回非零值。 The results of each of the four PRODUCT terms is tested with <>0 which will return TRUE if a value is not found. 使用<>0测试四个PRODUCT术语中的每一个的结果,如果未找到值,则返回TRUE。 Then OR with return TRUE if one or more values are not found and FALSE if all are found. 当时还是用回TRUE,如果没有找到,FALSE一个或多个值,如果所有被找到。 That result is wrapped in a NOT so that the function result is TRUE when all four values are found. 该结果包含在NOT中,以便在找到所有四个值时函数结果为TRUE。

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

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