Return a category lookup formula

tigerzen

Board Regular
Joined
Mar 8, 2023
Messages
209
Office Version
  1. 365
Platform
  1. Windows
Looking for a formula to populate the category column automatically so basically if the description column contains one of a series of words then a particular country is returned. The attached example will indicate what I'm trying to achieve with the desired solution just below the actual question.
Book6
ABCDEF
2ItemCategoryEuropeUSAsia
3Paris FranceFranceTexasChina
4Belgium wafflesBelgiumNew YorkThailand
5Texas hotcakesAustriaJapan
6Statues in AustriaItaly
7soup in China
8Japan sword
9
10ItemCategory
11Paris FranceEurope
12Belgium wafflesEurope
13Texas hotcakesUS
14Statues in AustriaEurope
15soup in ChinaAsia
16Japan swordAsia
Sheet1
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
First I would suggest you make your lookup a flat lookup with two columns one for the country and one for the continent.
but, if that is impossible, you can use this. It is very complicated:

Book1
ABCDEF
1ItemCategoryEuropeUSAsia
2Paris FranceEuropeFranceTexasChina
3Belgium wafflesEuropeBelgiumNew YorkThailand
4Texas hotcakesUSAustriaJapan
5Statues in AustriaEuropeItaly
6soup in ChinaAsia
7Japan swordAsia
8
9ItemCategory
10Paris FranceEurope
11Belgium wafflesEurope
12Texas hotcakesUS
13Statues in AustriaEurope
14soup in ChinaAsia
15Japan swordAsia
16
Sheet1
Cell Formulas
RangeFormula
B2:B7B2=INDEX(TAKE(TEXTSPLIT(TEXTJOIN(",",TRUE,$E$2:$E$3&";"&$E$1) & "," & TEXTJOIN(",",TRUE,$F$2:$F$4&";"&$F$1) & "," & TEXTJOIN(",",TRUE,$D$2:$D$5&";"&$D$1),";",","),,-1),MATCH(INDEX(TEXTSPLIT(A2," "),SUM((--(ISNUMBER(MATCH(TEXTSPLIT(A2," "),TAKE(TEXTSPLIT(TEXTJOIN(",",TRUE,$E$2:$E$3&";"&$E$1) & "," & TEXTJOIN(",",TRUE,$F$2:$F$4&";"&$F$1) & "," & TEXTJOIN(",",TRUE,$D$2:$D$5&";"&$D$1),";",","),,1),0))))*SEQUENCE(,COUNTA(TEXTSPLIT(A2," ")),1,1))),TAKE(TEXTSPLIT(TEXTJOIN(",",TRUE,$E$2:$E$3&";"&$E$1) & "," & TEXTJOIN(",",TRUE,$F$2:$F$4&";"&$F$1) & "," & TEXTJOIN(",",TRUE,$D$2:$D$5&";"&$D$1),";",","),,1),0))
 
Upvote 0
Here is a miniworkbook with both approaches:
Book1
ABCDEFGHI
1ItemCategoryBetterEuropeUSAsiaFranceEurope
2Paris FranceEuropeEuropeFranceTexasChinaBelgiumEurope
3Belgium wafflesEuropeEuropeBelgiumNew YorkThailandAustriaEurope
4Texas hotcakesUSUSAustriaJapanItalyEurope
5Statues in AustriaEuropeEuropeItalyTexasUS
6soup in ChinaAsiaAsiaNew YorkUS
7Japan swordAsiaAsiaChinaAsia
8ThailandAsia
9ItemCategoryJapanAsia
10Paris FranceEurope
11Belgium wafflesEurope
12Texas hotcakesUS
13Statues in AustriaEurope
14soup in ChinaAsia
15Japan swordAsia
16
Sheet1
Cell Formulas
RangeFormula
B2:B7B2=INDEX(TAKE(TEXTSPLIT(TEXTJOIN(",",TRUE,$E$2:$E$3&";"&$E$1) & "," & TEXTJOIN(",",TRUE,$F$2:$F$4&";"&$F$1) & "," & TEXTJOIN(",",TRUE,$D$2:$D$5&";"&$D$1),";",","),,-1),MATCH(INDEX(TEXTSPLIT(A2," "),SUM((--(ISNUMBER(MATCH(TEXTSPLIT(A2," "),TAKE(TEXTSPLIT(TEXTJOIN(",",TRUE,$E$2:$E$3&";"&$E$1) & "," & TEXTJOIN(",",TRUE,$F$2:$F$4&";"&$F$1) & "," & TEXTJOIN(",",TRUE,$D$2:$D$5&";"&$D$1),";",","),,1),0))))*SEQUENCE(,COUNTA(TEXTSPLIT(A2," ")),1,1))),TAKE(TEXTSPLIT(TEXTJOIN(",",TRUE,$E$2:$E$3&";"&$E$1) & "," & TEXTJOIN(",",TRUE,$F$2:$F$4&";"&$F$1) & "," & TEXTJOIN(",",TRUE,$D$2:$D$5&";"&$D$1),";",","),,1),0))
C2:C7C2=INDEX($I$1:$I$9,SUM(IFERROR(MATCH(TEXTSPLIT(A2," "),$H$1:$H$9,0),0)),0)
 
Upvote 0
Another option
Fluff.xlsm
ABCDEF
1ItemCategoryEuropeUSAsia
2Paris FranceEuropeFranceTexasChina
3Belgium wafflesEuropeBelgiumNew YorkThailand
4Texas hotcakesUSAustriaJapan
5Statues in AustriaEuropeItaly
6soup in ChinaAsia
7Japan swordAsia
8
Main
Cell Formulas
RangeFormula
B2:B7B2=TOCOL(VLOOKUP(TEXTSPLIT(A2," "),HSTACK(TOCOL($D$2:$F$7,1),TOCOL(IF($D$2:$F$7<>"",$D$1:$F$1,1/0),2)),2,0),2)
 
Upvote 0
Thanks guys a 2 columnar approach is perfectly fine, I'd like to avoid any unnecessary complication wherever possible.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Excel Formula:
=INDEX($D$1:$F$1,,AGGREGATE(14,6,IF(SEARCH(IF($D$2:$F$5<>"",$D$2:$F$5),A2)>0,COLUMN($D$1:$F$1))-3,1))

1680448718750.png
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top