Search code examples
excelfindxlookup

Excel XLOOKUP - find and return data containing text, but exclude if it includes other text


I have xlookup function searching range F1:F44 for the text in F2 and then returning the match:

XLOOKUP(TRUE,ISNUMBER(FIND(F2,F1:F44)),F1:F44,,2)

However I need to exclude entries if they include text listed in array A1:A10.

I have tried switching over to something like this with the NOT, but always get an error:

=XLOOKUP(TRUE,(ISNUMBER(FIND(F2,F1:F44))*NOT(A1:A10),F1:F44))

I also tried

=XLOOKUP(TRUE,ISNUMBER(FIND(F2,F1:F44)*NOT(FIND(A1,F1:F44))),F1:F44,"no match",2)

but in this case the result being returned contains the value in A1 that is supposed to be excluded with the "NOT".

Tried applying this suggestion:

=XLOOKUP(1,ISNUMBER(FIND(G2,DumpSample!F1:F44))*(MMULT(--ISNUMBER(FIND(TRANSPOSE(exclude!A1:A8),DumpSample!F1:F44)),SEQUENCE(ROWS(exclude!A1:A8)))=0),DumpSample!F1:F44,"no match",2)

and it seems to be working.


Solution

  • use

    =XLOOKUP(1,ISNUMBER(FIND(F2,F1:F44))*(MMULT(--ISNUMBER(FIND(TRANSPOSE(A1:A10),F1:F44)),SEQUENCE(ROWS(A1:A10)))=0),F1:F44,"no match",2)
    

    The MMULT()=0 will return an array of TRUE/FALSE. TRUE if none of the values in A1:A10 are found in the cell, FALSE if found

    Also where multiplying two Boolean we get either 1 or 0 so instead of TRUE we need to look for 1

    ![enter image description here