SOLVED

Cell contains specific word and return that specific word in another cell

%3CLINGO-SUB%20id%3D%22lingo-sub-1366208%22%20slang%3D%22en-US%22%3ECell%20contains%20specific%20word%20and%20return%20that%20specific%20word%20in%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1366208%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Team%2C%3C%2FP%3E%3CP%3EGreetings!%20Hope%20everyone%20is%20safe%20and%20doing%20well.%3C%2FP%3E%3CP%3EI%20am%20new%20to%20excel%20and%20learning%20few%20of%20its%20functions%2Fformula%20on%20daily%20basis.%20I%20need%20help%20on%20below%20criteria%2C%20that%20seems%20to%20be%20advanced%20one%2C%20Please%20could%20someone%20review%20and%20suggest%20to%20get%20to%20the%20result.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExcel%20version%3A%202016%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EWorksheet%231%20%5BFinal%20Data%5D%20%5Baround%206000%20rows%5D%3C%2FSTRONG%3E%3C%2FP%3E%3CTABLE%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EColumn%3AA%3C%2FP%3E%3CP%3ERow%3A1%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EColumn%3AB%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EColumn%3AC%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EColumn%3AD%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3ERow%3A2%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3ENo.%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E%3CSTRONG%3ECountry%20%5BResult%20to%20be%20displayed%20here%2C%20i.e.%20Country%20Name%5D%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EDescription%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3ERow%3A3%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E1%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EEgypt%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EThe%20pyramids%20are%20in%20Egypt.%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3ERow%3A4%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E2%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EJapan%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EJapan%20is%20in%20APAC%20region%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3ERow%3A5%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E3%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EAustralia%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3EThe%20Red%20Kangaroo%20is%20the%20national%20animal%20of%20Australia.%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E---%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E---%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E---%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E---%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3ERow%3An%3B%20n%20%3D%206000%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E6223%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3CTD%20width%3D%2225%25%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26gt%3B%26gt%3B%26nbsp%3B%20please%20note%20that%20result%20word%20(country%20name)%20can%20be%20either%20in%20start%20or%20middle%20or%20end%20of%20the%20description.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EWorksheet%232%20%5BCountry%20List%5D%20%5Bincludes%20single%20column%20of%20number%20of%20countries%5D%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EColumn%3A%20c%20%3D%20list%20of%20countries%3C%2FP%3E%3CP%3EJapan%3C%2FP%3E%3CP%3EIndia%3C%2FP%3E%3CP%3EFrance%3C%2FP%3E%3CP%3EEgypt%3C%2FP%3E%3CP%3EChina%3C%2FP%3E%3CP%3EParis%3C%2FP%3E%3CP%3E......%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ELogic%3A%26nbsp%3B%3C%2FSTRONG%3Elook%20the%20description%20(column%3AD%2C%20worksheet%231)%20and%20find%20specific%20word%20(country%20name)%2C%20search%20or%20lookup%20that%20country%20name%20in%20(column%3Ac%2C%20worksheet%232%20-%20i%20gave%20a%20name%20list%20(for%20workbook)%20to%20it%2C%20i.e.%20to%20column%3A%20%24c%3A%24c%20%3D%20clist%20(country%20list)%20and%20return%20value%20in%20Column%3AC%20(worksheet%231).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20below%20formula%20but%20that%20is%20array%20and%20i%20have%20around%206000%20rows%2C%20also%20other%20formulas%20-%20which%20results%20in%20lot%20of%20processing%20and%20excel%20goes%20hung.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eref.%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.get-digital-help.com%2Fif-cell-contains-text-from-list%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.get-digital-help.com%2Fif-cell-contains-text-from-list%2F%3C%2FA%3E%3C%2FP%3E%3CP%3EFormula%3A%26nbsp%3B%3DIFERROR(INDEX(%24G%243%3A%24G%247%2C%20SMALL(IF(COUNTIF(%24B3%2C%20%22*%22%26amp%3B%24G%243%3A%24G%247%26amp%3B%22*%22)%2C%20MATCH(ROW(%24G%243%3A%24G%247)%2C%20ROW(%24G%243%3A%24G%247))%2C%20%22%22)%2C%20COLUMNS(%24A%241%3AA1)))%2C%20%22%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eused%20below%20formula%20but%20super%20slow%20and%20excel%20hungs-%3C%2FP%3E%3CP%3EIFERROR(INDEX(clist%2CSMALL(IF(COUNTIF(%24C3%2C%22*%22%26amp%3Bclist%26amp%3B%22*%22)%2CMATCH(ROW(clist)%2CROW(clist))%2C%22%22)%2CCOLUMNS(%24A%241%3AA1)))%2C%22%22)%20CTRL%2BSHIFT%2BENTER%20%5Barray%20formula%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EQuestion%3A%3C%2FP%3E%3CP%3Eis%20there%20any%20other%20way%20of%20applying%20formula%20so%20excel%20won't%20hung%20and%20speed%20can%20be%20optimized%20even%20with%20more%20data%20to%20be%20populated%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAppreciate%20your%20advise%20on%20the%20same..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3EBaiju%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1366208%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ENeed%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1377444%22%20slang%3D%22en-US%22%3ERe%3A%20Cell%20contains%20specific%20word%20and%20return%20that%20specific%20word%20in%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1377444%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F658950%22%20target%3D%22_blank%22%3E%40soniba2%3C%2FA%3E%26nbsp%3BThe%20attached%20solution%20may%20work%20for%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1377623%22%20slang%3D%22en-US%22%3ERe%3A%20Cell%20contains%20specific%20word%20and%20return%20that%20specific%20word%20in%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1377623%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much!%20it%20helped..and%20is%20working%20fast%20with%20negligible%20slowness%20due%20to%20the%20bunch%20of%20data%20and%20formula.%3C%2FP%3E%3CP%3Ei%20understand%20that%20we%20have%20created%20table%20for%20the%20countries%20list%2C%20apart%20from%20that%20other%20areas%20-%20i%20couldn't%20determine...%3C%2FP%3E%3CP%3Ecan%20you%20please%20also%2C%20advise%20to%20get%20better%20on%20the%20excel%20-%20with%20its%20use%20and%20formulas%3F%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20Regards%2C%3C%2FP%3E%3CP%3EBaiju%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1377679%22%20slang%3D%22en-US%22%3ERe%3A%20Cell%20contains%20specific%20word%20and%20return%20that%20specific%20word%20in%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1377679%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F658950%22%20target%3D%22_blank%22%3E%40soniba2%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIndeed%2C%20I%20put%20the%20country%20list%20in%20a%20structured%20table.%20You%20can%20add%20countries%20to%20the%20list%20without%20having%20to%20worry%20about%20expanding%20the%20ranges%20used%20in%20the%20formula.%20You%20can%20move%20it%20anywhere%20you%20like%20in%20your%20workbook%2C%20as%20long%20as%20the%20table%20is%20called%20%22Countries%22%20and%20the%20column%20header%20%22Country%22.%20But%2C%20I%20could%20have%20used%20a%20regular%20reference%20to%20the%20list%20or%20I%20could%20have%20created%20a%20dynamic%20named%20range%20the%20country%20list.%20Many%20different%20options!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%2C%20as%20for%20the%20formula%2C%20start%20reading%20it%20inside%20out.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIFERROR(INDEX(Countries%5BCountry%5D%2CMATCH(TRUE%2C(ISNUMBER(SEARCH(Countries%5BCountry%5D%2CC3%2C1)))%2C0)%2C1)%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSTRONG%3ESEARCH(Countries%5BCountry%5D%2CC3%2C1)%3C%2FSTRONG%3E%20determines%20if%20any%20of%20the%20countries%20in%20the%20list%20exists%20in%20cell%20C3%2C%20starting%20at%20the%20first%20character.%20It%20will%20return%20a%20number%20for%20the%20position%20(%3Dindex)%20in%20the%20list%20if%20found.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EISNUMBER(-----------------)%3C%2FSTRONG%3E%20will%20return%20TRUE%20if%20the%20country%20was%20found%2C%20FALSE%20if%20not%20found.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EMATCH(TRUE%2C(-------------)%2C0)%3C%2FSTRONG%3E%20will%20return%20the%20index%20if%20TRUE%20ar%20and%20error%20is%20FALSE.%20The%20zero%20at%20the%20end%20means%20it%20looks%20for%20an%20exact%20match.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EINDEX(Countries%5BCountry%5D%2C--------%2C1)%3C%2FSTRONG%3E%20will%20return%20the%20name%20of%20the%20country%20based%20on%20the%20result%20from%20the%20previous%20step.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EIFERROR(----------%2C%22%22)%3C%2FSTRONG%3E%20captures%20the%20error%20in%20the%20MATCH%20step%20(if%20applicable)%20and%20returns%20a%20blank%2C%20rather%20than%20the%20error%20message.%20You%20can%20enter%2C%20e.g.%20%22No%20country%20name%20found%22%20in%20stead%20of%20%22%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHaving%20said%20all%20this%2C%20note%20that%20there%20is%20one%20weakness%20with%20this%20approach.%20Should%20you%20have%20sentence%20like%20%22Japanese%20people%20live%20in%20France%22%2C%20it%20will%20return%20Japan%20as%20a%20part%20of%20%22%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3EJapan%3C%2FFONT%3E%3C%2FSTRONG%3Eese%22%20%3CSTRONG%3Eand%3C%2FSTRONG%3E%20because%20Japan%20is%20in%20the%20list%20before%20France.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1381456%22%20slang%3D%22en-US%22%3ERe%3A%20Cell%20contains%20specific%20word%20and%20return%20that%20specific%20word%20in%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1381456%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethank%20you!%20Riny%20for%20the%20explanation.%3C%2FP%3E%3CP%3Eyes%2C%20your%20point%20is%20valid%20if%20two%20or%20more%20countries%20in%20description%20cell%20is%20mentioned%3B%20need%20to%20figure%20out%20on%20the%20same.%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3EBaiju%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi Team,

Greetings! Hope everyone is safe and doing well.

I am new to excel and learning few of its functions/formula on daily basis. I need help on below criteria, that seems to be advanced one, Please could someone review and suggest to get to the result.

 

Excel version: 2016

 

Worksheet#1 [Final Data] [around 6000 rows]

Column:A

Row:1

Column:B

Column:C

Column:D

Row:2

No.

Country [Result to be displayed here, i.e. Country Name]

Description

Row:3

1

Egypt

The pyramids are in Egypt.

Row:4

2

Japan

Japan is in APAC region

Row:5

3

Australia

The Red Kangaroo is the national animal of Australia.

---

---

---

---

Row:n; n = 6000

6223

 

 

 

>>  please note that result word (country name) can be either in start or middle or end of the description.

 

Worksheet#2 [Country List] [includes single column of number of countries]

Column: c = list of countries

Japan

India

France

Egypt

China

Paris

......

 

Logic: look the description (column:D, worksheet#1) and find specific word (country name), search or lookup that country name in (column:c, worksheet#2 - i gave a name list (for workbook) to it, i.e. to column: $c:$c = clist (country list) and return value in Column:C (worksheet#1).

 

I found below formula but that is array and i have around 6000 rows, also other formulas - which results in lot of processing and excel goes hung. 

 

ref.: 

https://www.get-digital-help.com/if-cell-contains-text-from-list/

Formula: =IFERROR(INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, "*"&$G$3:$G$7&"*"), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), ""), COLUMNS($A$1:A1))), "")

 

used below formula but super slow and excel hungs-

IFERROR(INDEX(clist,SMALL(IF(COUNTIF($C3,"*"&clist&"*"),MATCH(ROW(clist),ROW(clist)),""),COLUMNS($A$1:A1))),"") CTRL+SHIFT+ENTER [array formula]

 

Question:

is there any other way of applying formula so excel won't hung and speed can be optimized even with more data to be populated?

 

Appreciate your advise on the same..

 

Thanks!

Baiju

4 Replies
Highlighted
Best Response confirmed by soniba2 (New Contributor)
Solution

@soniba2 The attached solution may work for you.

 

 

Highlighted

@Riny_van_Eekelen 

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

Highlighted

@soniba2 

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.

 

 

 

Highlighted

@Riny_van_Eekelen 

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