0

Example representation

I have a list of strings in Column A. I want to match the entries in column G (partial strings) with the strings in column A. If there is a match, I want to print out the partial string in Column B (output).

I have used the following formula -

=IF(SUMPRODUCT(--ISNUMBER(SEARCH(G:G,A1)))>0,"found","notfound")

to print out found or notfound string, but I am not able to print out the partial string value in column B.

Any help would be appreciated.

1 Answer 1

1

You can use INDEX with an AGGREGATE to return the row number:

=IFERROR(INDEX(G:G,AGGREGATE(15,6,ROW($G$2:$G$3)/(ISNUMBER(SEARCH($G$2:$G$3,A2))),1)),"")

Aggregate is an array type formula and as such the references needs to be constrained to the data set and not a full column reference.

Also the sub string must match fully in the larger string, in your example Please contact agent would not be found in Please contact the agent As the splits the string and will not match.

enter image description here


To make the formula more dynamic, so it does not need to be edited every time a sub-string is added or removed from the list and still maintain the smallest reference we can use another INDEX/MATCH to find the end of the list and set this as the end of the reference.

=IFERROR(INDEX(G:G,AGGREGATE(15,6,ROW($G$2:INDEX(G:G,MATCH("ZZZZ",G:G)))/(ISNUMBER(SEARCH($G$2:INDEX(G:G,MATCH("ZZZZ",G:G)),A2))),1)),"")
Sign up to request clarification or add additional context in comments.

5 Comments

Is it just me? Why your formula is not returning anything for me?
@ManishChristian I did not photo-shop the picture, it is working as advertised for me. Check to ensure that the text matches. Try just doing the SEARCH part on the one cell that you think it should match and see if it returns an error, if so it is not finding the text inside the other.
I am not doubting your ability at all. I was just wondering why it's not working for me. Breaking and debugging it now.
Even simple SEARCH function is returning returning FALSE for Row5 using {=ISNUMBER(SEARCH($G$2:$G$3,A5))} formula. Upon evaluating this formula, it's just taking value of G2 as find_text and not G2 adn G3 both.
You need to have the formula inside another that forces the iteration. That formula alone will not do that. Either an Aggregate or Sumproduct will do it. So will MAX() or MIN() or SUM() as an array formula.

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.