Forum Discussion
Cell contains specific word and return that specific word in another cell
- May 10, 2020
Thank you very much! it helped..and is working fast with negligible slowness due to the bunch of data and formula.
i understand that we have created table for the countries list, apart from that other areas - i couldn't determine...
can you please also, advise to get better on the excel - with its use and formulas?
Best Regards,
Baiju
Indeed, I put the country list in a structured table. You can add countries to the list without having to worry about expanding the ranges used in the formula. You can move it anywhere you like in your workbook, as long as the table is called "Countries" and the column header "Country". But, I could have used a regular reference to the list or I could have created a dynamic named range the country list. Many different options!
Now, as for the formula, start reading it inside out.
=IFERROR(INDEX(Countries[Country],MATCH(TRUE,(ISNUMBER(SEARCH(Countries[Country],C3,1))),0),1),"")SEARCH(Countries[Country],C3,1) determines if any of the countries in the list exists in cell C3, starting at the first character. It will return a number for the position (=index) in the list if found.
ISNUMBER(-----------------) will return TRUE if the country was found, FALSE if not found.
MATCH(TRUE,(-------------),0) will return the index if TRUE ar and error is FALSE. The zero at the end means it looks for an exact match.
INDEX(Countries[Country],--------,1) will return the name of the country based on the result from the previous step.
IFERROR(----------,"") captures the error in the MATCH step (if applicable) and returns a blank, rather than the error message. You can enter, e.g. "No country name found" in stead of "".
Having said all this, note that there is one weakness with this approach. Should you have sentence like "Japanese people live in France", it will return Japan as a part of "Japanese" and because Japan is in the list before France.
- soniba2May 12, 2020Copper Contributor
thank you! Riny for the explanation.
yes, your point is valid if two or more countries in description cell is mentioned; need to figure out on the same.
Thanks!
Baiju