Excel Find the largest partial value in an indexed list

[亡魂溺海] 提交于 2020-01-03 02:54:13

问题


I am working with excel and trying to find if a portion of one cell matches anything from a list. I am attempting to extract that part of the cell as my result.

The formula I am working with is:

{=INDEX($A$1:$A$10,MATCH(1,COUNTIF(B1,"* "&$A$1:$A$10&"*"),0))}

note: had to space out the asterisk to avoid italics

A1 to A10 is the list i am referencing and anything in column B is what I am searching partail parts for in the list

The problem is the formula return the most common value found in the list instead of the most specific part of the list.

Example:

        A(list)          B           (formula result)  (desired Result)

1       ABC          sdfjABCsdhfs          ABC               ABC
2       ABC123       asdfasdfa             #N/A              #N/A
3       RBZ456       agfhABC1234shj        ABC               ABC1234
4       ABC1234      wuefhiuvbsiue         #N/A              #N/A
5       DEF123       dfsghABC123sdf        ABC               ABC123

The maximum result found in column B is what I am looking to find as my result. Not the lowest common denominator.

Any advice would be great!

Thanks in advance.

edit: added brackets, it is an array formula


回答1:


Array formula**:

=INDEX($A$1:$A$10,MATCH(MAX(IF(COUNTIF(B1," *"&$A$1:$A$10&" *"),LEN($A$1:$A$10))),IF(COUNTIF(B1," *"&$A$1:$A$10&" *"),LEN($A$1:$A$10)),0))

(I also added a single space before each of the four asterisks.)

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).



来源:https://stackoverflow.com/questions/26149352/excel-find-the-largest-partial-value-in-an-indexed-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!