0
votes

I'm trying to match a cell with comma separated numbers (M) against a column of numbers (B), such that if any of the comma separated numbers do NOT appear in the column, the result is false.

I have already this solution:

{=COUNT(MATCH(TRIM(MID(SUBSTITUTE(M2,",",REPT(" ",100)),(Num_Array-1)*100+1,100)),$B$2:$B$7,0))=(LEN(M2)-LEN(SUBSTITUTE(M2,",",""))+1)}

at this link:

https://www.mrexcel.com/forum/excel-questions/654920-match-comma-delimited-values-cell-against-individual-values-column.html

which works perfectly if all the values are text. But if all the values are numbers, it always returns false.

Test data I used is: test data

1
this solution fails on M5Matt Crandall

1 Answers

1
votes

You will need to iterate the values in each cell and test:

=SUMPRODUCT(--(ISNUMBER(MATCH(--TRIM(MID(SUBSTITUTE(M2,",",REPT(" ",999)),(ROW($XFD$1:INDEX($XFD:$XFD,LEN(M2)-LEN(SUBSTITUTE(M2,",",""))+1))-1)*999+1,999)),$B:$B,0))))=LEN(M2)-LEN(SUBSTITUTE(M2,",",""))+1

![enter image description here


Using your COUNT array formula:

=COUNT(MATCH(--TRIM(MID(SUBSTITUTE(M2,",",REPT(" ",999)),(ROW($XFD$1:INDEX($XFD:$XFD,LEN(M2)-LEN(SUBSTITUTE(M2,",",""))+1))-1)*999+1,999)),$B:$B,0))=LEN(M2)-LEN(SUBSTITUTE(M2,",",""))+1

Needs confirmation with Ctrl-Shift-Enter to work.

I prefer the SUMPRODUCT because it does not need the Ctrl-Shift-Enter confirmation.