5

I have a column of text values (column C below), they are of varying length. I have a separate array of text values (column A below). I want a formula that will look through the strings in Column C and return the word from Column A that it matches. If there are multiple matches (rare, probably won't happen), it will only return one.

Please see my example:

Example

Column D is the result I am looking for. As you can see, this will require some kind of fuzzy string matching. The word could appear anywhere in the cell. It doesn't need to be case sensitive. But I need it to pull that word out of the string as the result basically.

Thank you!

4 Answers 4

7

Use This:

=INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$5)/(ISNUMBER(SEARCH($A$2:$A$5,C2))),1))

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Perfection. Thank you so much!
This is a beautiful solution! Can you please explain how your answer works? The AGGREGATE function, in particular, has always been a challenge for me and I don't personally know anyone who uses it. Is your formula simply returning the first value in the $A$2:$A$5 list that causes the division part of the formula to return a non-error value?
2

One more, slightly simpler:

=IF(COUNTIF($C$1:$C$100," * "&A2&" * ")>0,A2,"")

Comments

0

You can also try this formula =INDEX(A:A,SUMPRODUCT(MATCH(1,NOT(ISERR(SEARCH(A:A,C2)))*1,0))). Enter it using CTRL+SHIFT+ENTER since it is an array formula.

enter image description here

2 Comments

1. When using array formulas one should limit the sized of the referenced data to the data set to lessen the unneeded number of iterations. Currently your formulas are doing over 5 million calculations. 2. Your formula can be simplified to =INDEX($A$2:$A$5,MATCH(1,ISNUMBER(SEARCH($A$2:$A$5,C2))*1,0)) No need for SUMPRODUCT when using Ctrl-Shift-Enter.
Thanks you, it was more a matter of speed that I left search with whole column referenced...but for 2. definitively more elegant solution.
0

This formula seems to be working for me: (Please use Ctrl+Shift+Enter for the array formula to take effect)

{=INDEX($A$2:$A$5,MATCH(1,COUNTIF(C2,"*"&$A$2:$A$5&"*"),0))}

Screenshot of Excel sheet

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.