Forum Discussion

John_Hartman's avatar
John_Hartman
Copper Contributor
Nov 08, 2023
Solved

How can I use XLOOKUP to find the cell with a contains?

I have a table that has a cell that concatenates groups. This cell may have multiple values and they're not always in the same order due to the program that spits them out.

 

NameGroup(desired formula)
ex1ABCABC
ex2DEF-1, DEFDEF
ex3DEF, DEF-1DEF
ex4

GHI-2

, GHI-1, GHI

GHI
ex5JKLJKL

 

The table above has two columns of data that I have and the third column is what I'm trying to get.

 

I have another table for reference that simply has all the actual three letter combinations at a high level. I'm not concerned about the -1 or -2 sub groups. I simply need the three letter group that it belongs to.

 

reference table (Groups)

Group

ABC

DEF
GHI
JKL

 

How would I write the formula into C2 in the first table for example to get those desired three letter high level groups?

 

=XLOOKUP(B2,Groups!$A$2:$A$5,Groups!$A$2:$A$5)

The above gets me a match if the cell perfectly matches but I'm struggling to figure out how to make it search the text in B2 for a match from the table of Groups.

 

  • John_Hartman 

    =INDEX($G$3:$G$6,XMATCH(TRUE,ISNUMBER(SEARCH($G$3:$G$6,B2))))

     

    This formula works in my Excel for the web sheet.

    • John_Hartman's avatar
      John_Hartman
      Copper Contributor
      That's exactly what I needed! I figured the answer was going to use something other than XLOOKUP. I'll keep INDEX and XMATCH in my toolbelt from now on.

      Thank you

Resources