Lookup of some kind, search in two columns, delimiter in 2nd column

newbieexcel24

New Member
Joined
Mar 14, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have a library of chemicals with their category assigned.

The first column is chemical name, second column is alternative chemical names, third column is category.

Chemical nameAlternative chemical nameCategory
AnilinePhenylamineTOL
Formic acidMethanoic acidACL
Acetic acidEthanoic acid; methane carboxylic acid; Glacial acidFXL
Sodium hydroxideALL
Pyrogallol1,2,3-Benzenetriol;
1,2,3-Trihydroxybenzene; benzene-1,2,3-triol
LHS

VlookupResults
Methanoic acidACL
Ethanoic acidFXL
Anline TOL
1,2,3-TrihydroxybenzeneLHS

How would I be able to achieve this?

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Two questions:
1. What version of Excel are you using? You can update account details to show this…important because optimal solutions often depend on the version.
2. What are you trying to accomplish? Do you want to transform the source data into a two column table, or do you want to enter a chemical name in the left column and have a formula deliver the category?
 
Upvote 0
Like This ?

Excel Formula:
=IFERROR(LOOKUP(2,1/ISNUMBER(SEARCH(F2,$B$2:$B$6)),$C$2:$C$6),VLOOKUP(F2,$A$2:$C$6,3,0))

1710465373485.png
 
Upvote 0
Like This ?

Excel Formula:
=IFERROR(LOOKUP(2,1/ISNUMBER(SEARCH(F2,$B$2:$B$6)),$C$2:$C$6),VLOOKUP(F2,$A$2:$C$6,3,0))
That formula is unreliable. Try swapping the values in A3:C3 with those in A5:C5 and then look at your result for "Ethanoic acid".
 
Upvote 0
Two questions:
1. What version of Excel are you using? You can update account details to show this…important because optimal solutions often depend on the version.
2. What are you trying to accomplish? Do you want to transform the source data into a two column table, or do you want to enter a chemical name in the left column and have a formula deliver the category?
1. I am using Office 365
2. My apologies, it was late when I posted this, I should have put more information in. I'm trying to achieve a full match by looking into the first column, if no match, it then goes onto the second column and look in that for a full match, if still no match, it would then return 'Not found'. The formula will need to take the delimiters (;) in the second column in consideration. What I'm looking to do is paste in a list of chemicals which will then return the categories for each of the chemicals - which is the latter you said. I hope that's all the information you need?
 
Upvote 0
1. I am using Office 365
Please update your forum profile with that information (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

See if this does what you want.

24 03 15.xlsm
ABC
1Chemical nameAlternative chemical nameCategory
2AnilinePhenylamineTOL
3Formic acidMethanoic acidACL
4Acetic acidEthanoic acid; methane carboxylic acid; Glacial acidFXL
5Sodium hydroxideALL
6Pyrogallol1,2,3-Benzenetriol; 1,2,3-Trihydroxybenzene; benzene-1,2,3-triolLHS
7
8
9VlookupResults
10Methanoic acidACL
11Ethanoic acidFXL
12AnilineTOL
131,2,3-TrihydroxybenzeneLHS
14Something elseNot found
Lookup
Cell Formulas
RangeFormula
B10:B14B10=XLOOKUP(A10,A$2:A$6,C$2:C$6,XLOOKUP("*; "&A10&";*","; "&SUBSTITUTE(B$2:B$6,CHAR(10)," ")&";",C$2:C$6,"Not found",2))
 
Upvote 0
Please update your forum profile with that information (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

See if this does what you want.

24 03 15.xlsm
ABC
1Chemical nameAlternative chemical nameCategory
2AnilinePhenylamineTOL
3Formic acidMethanoic acidACL
4Acetic acidEthanoic acid; methane carboxylic acid; Glacial acidFXL
5Sodium hydroxideALL
6Pyrogallol1,2,3-Benzenetriol; 1,2,3-Trihydroxybenzene; benzene-1,2,3-triolLHS
7
8
9VlookupResults
10Methanoic acidACL
11Ethanoic acidFXL
12AnilineTOL
131,2,3-TrihydroxybenzeneLHS
14Something elseNot found
Lookup
Cell Formulas
RangeFormula
B10:B14B10=XLOOKUP(A10,A$2:A$6,C$2:C$6,XLOOKUP("*; "&A10&";*","; "&SUBSTITUTE(B$2:B$6,CHAR(10)," ")&";",C$2:C$6,"Not found",2))
Brilliant, thank you. I was having an headache with the delimiter factor. I appreciate that and I have updated my account.
 
Upvote 0
Thanks for the clarification. Initially I thought that you might want to create a flat table (a two-column table consisting of only Chemical/Alternative Names and Category). And from the image, it isn't clear whether the apparent text wrapping after 1,2,3-Benzenetriol; is due to a space or a line feed...which would create a delimiter problem, so some effort is needed to address that (maybe not necessary in reality?). If a flat table were desired and Excel 365 were an option (now I see the former is "no" and the latter "yes"), then the flat can be formed as shown in I2. And if a lookup is desired, the flat table can be created internal to the formula and passed to the lookup formula as in A10. More convoluted that Peter's solution, but the flat table might be useful for other purposes. The formula assumes that no delimiters appear at the end of entries in columns A and B.
Book1 (version 2).xlsb
ABCDIJ
1Chemical nameAlternative chemical nameCategoryChemical nameCategory
2AnilinePhenylamineTOLAnilineTOL
3Formic acidMethanoic acidACLPhenylamineTOL
4 Acetic acidEthanoic acid ; methane carboxylic acid;Glacial acidFXLFormic acidACL
5 Sodium hydroxideALLMethanoic acidACL
6Pyrogallol1,2,3-Benzenetriol; 1,2,3-Trihydroxybenzene; benzene-1,2,3-triolLHS Acetic acidFXL
7Ethanoic acidFXL
8methane carboxylic acidFXL
9Glacial acidFXL
10Methanoic acidACL Sodium hydroxideALL
11Ethanoic acidFXLPyrogallolLHS
12AnilineTOL1,2,3-BenzenetriolLHS
131,2,3-TrihydroxybenzeneLHS1,2,3-TrihydroxybenzeneLHS
14Something elseNot foundbenzene-1,2,3-triolLHS
151,2,3-BenzenetriolLHS
16glacial acidFXL
17benzeneNot found
18methane carboxylic acidFXL
Sheet2
Cell Formulas
RangeFormula
I2:J14I2=LET(b,SUBSTITUTE($B$2:$B$6,CHAR(10)," "),TRIM(TEXTSPLIT(CONCAT(SUBSTITUTE($A$2:$A$6&IF(b="","",";"&b)&";",";",";"&$C$2:$C$6&"|")),";","|",1)))
B10:B18B10=LET(b,SUBSTITUTE($B$2:$B$6,CHAR(10)," "),ft,TRIM(TEXTSPLIT(CONCAT(SUBSTITUTE($A$2:$A$6&IF(b="","",";"&b)&";",";",";"&$C$2:$C$6&"|")),";","|",1)), XLOOKUP(A10,INDEX(ft,,1),INDEX(ft,,2),"Not found"))
Dynamic array formulas.
 
Upvote 0
You are welcome. Thanks for the follow-up. :)

.. and for updating your profile. (y)
 
Upvote 0

Forum statistics

Threads
1,215,197
Messages
6,123,585
Members
449,108
Latest member
rache47

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