Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel formula that would search multiple text based on another cell in single cell

I want to search formula that would search multiple text in cell 1 contain in cell 2 but the position is random, please see the result column that I want. For example,

example

I expected as the result column.

Here the data in Table Markdown format:

Cell 1 Cell 2 Result
"Yellow, Black, Red, Green, Purple" "Black, Red, Green, Orange" FALSE
"Yellos, Black, Red, Green, Purple" "Black, Red, Green" FALSE
"Yellow, Red, Green, Purple" "Yellow, Green, Red, Purple" TRUE
"Yellow, Green, Purple" "Purple, Green, Yellow" TRUE
like image 433
Boscha Avatar asked Sep 17 '25 12:09

Boscha


1 Answers

Compare Substrings in Two Columns

enter image description here

BYROW (Range)

  • The strings in the two columns (fCol, sCol) of each row (r) of the range (data) are compared using the function (f).
=LET(data,A2:B5,fCol,1,sCol,2,dl,", ",cl,"""",
    f,LAMBDA(x,IFERROR(TEXTJOIN(dl,,SORT(
        TEXTSPLIT(SUBSTITUTE(x,cl,""),,dl))),"")),
BYROW(data,LAMBDA(r,
    f(INDEX(r,,fCol))=f(INDEX(r,,sCol)))))

MAP (Two Columns)

  • The strings in each row of the two columns (fi, se (i, e)) are compared using the function (f).
=LET(fi,A2:A5,se,B2:B5,dl,", ",cl,"""",
    f,LAMBDA(x,IFERROR(TEXTJOIN(dl,,SORT(
        TEXTSPLIT(SUBSTITUTE(x,cl,""),,dl))),"")),
MAP(fi,se,LAMBDA(i,e,f(i)=f(e))))

The Function (f)

  • SUBSTITUTE is used to remove the double quotes (cl) from the string.
  • TEXTSPLIT is used to return the string split by the delimiter (dl) in a column.
  • SORT is used to sort the column ascending.
  • TEXTJOIN with the delimiter (dl) is used to return the column in a (delimited) string.
like image 93
VBasic2008 Avatar answered Sep 19 '25 06:09

VBasic2008