索引匹配通配符和多个标准

索引匹配通配符和多个标准

本文介绍了索引匹配通配符和多个标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用过这种形式的 INDEX(MATCH())公式,但从未使用通配符。任何人都可以解释为什么添加 A2&*会返回一个错误值?我已经检查了数据,绝对应该是一场比赛。



公式如下:

  {= INDEX(I1 :M1000,MATCH(1,(M1:M1000 = Sheet3!B1)*(I1:I1000 = A2&*),0),2)} 


解决方案

假设A2包含abc。



匹配语句的搜索字符串中的通配符例如

  MATCH(A2&*,I1:I1000,0)
/ pre>

搜索以abc开头的任何内容,但不在您要搜索的范围内。



另外,括号

 (I1:I1000 = A2& *)

只是将I1:I1000中的每个单元格与A2&*进行比较所以在这种情况下,它只是使用abc *进行每个单元格的文字匹配,而*不能作为通配符。



您可以尝试使用FIND或搜索进行部分匹配或使用LEFT获取I1中的字符串的前几个字符:I1000

  = INDEX(I1 :M1000,MATCH(1,(M1:M1000 = B1)*(FIND(A2,I1:I1000)= 1),0),2)

= INDEX(I1:M1000,MATCH 1,(M1:M1000 = B1)*(LEFT(I1:I1000,LEN(A2))= A2),0),2)

如果您使用IF语句重新设置公式,您还可以使用通配符: -

  = INDEX(I1:M1000,MATCH(A2&*,IF(M1:M1000 = B1,I1:I1000),0),2)
pre>

I have used INDEX(MATCH()) formulas of this form before, but never with wildcards. Could anyone explain as two why adding in the A2&"*" would return an error value? I have checked the data and there definitely should be a match.

The formula is as below:

{=INDEX(I1:M1000,MATCH(1,(M1:M1000=Sheet3!B1)*(I1:I1000=A2&"*"),0),2)}
解决方案

Suppose A2 contains "abc".

You can put a wild card in the search string of a match statement e.g.

MATCH(A2&"*",I1:I1000,0)

to search for anything beginning with abc, but not in the range that you're searching.

Also, the bracket

(I1:I1000=A2&"*")

is just comparing each cell in the range I1:I1000 with A2&"*" so in this context it just does a literal match of each cell with "abc*" and the * doesn't work as a wildcard.

You could try using FIND or SEARCH to do a partial match or using LEFT to get the first few characters of the strings in I1:I1000

=INDEX(I1:M1000,MATCH(1,(M1:M1000=B1)*(FIND(A2,I1:I1000)=1),0),2)

=INDEX(I1:M1000,MATCH(1,(M1:M1000=B1)*(LEFT(I1:I1000,LEN(A2))=A2),0),2)

You could also still use a wildcard if you re-cast the formula using an IF statement:-

=INDEX(I1:M1000,MATCH(A2&"*",IF(M1:M1000=B1,I1:I1000),0),2)

这篇关于索引匹配通配符和多个标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:53