PDA

View Full Version : [SOLVED:] Comparing two range of cells to find out the number of matches



Mati44
10-18-2017, 05:17 AM
I need a formula to compare two range of cells, say A1:E1 (1,2,3,4,5) and A2:E2 (2,3,1,4,5) , and if they have the same values (the numbers can be in different order), it will show the number of matches. The cells may have repetitions too ( e.g, 1,2,2,2,3). Thanks.

Mati44
10-18-2017, 06:25 AM
Thanks. I found the answer. here it is:=SUMPRODUCT(COUNTIF(A1:E1,A2:E2))
I am open to alternative solutions too though.

Mati44
10-19-2017, 04:56 AM
The formula I wrote above is not 100% correct unfortunately, I realized that after posting. For example, {1,1,1,1,1} and {1,1,1,1,1} are two groups with same numbers. so they are 5 matches. So I still need a formula for this task. Another example: {1,2,4,5,6} and {1,2,2,4,5} here the number of matches should be 4. The formula needs to count 2 one time because it is repeated only in the second group. The first group has only one 2. I am open to any suggestions. Thanks.

JKwan
10-19-2017, 06:41 AM
try this formula:

=SUMPRODUCT(SIGN(COUNTIF(A1:E1,A2:E2)))

Mati44
10-19-2017, 07:07 AM
When I try this formula with these numbers {1,3,2,6,6} and {3,3,4,5,6}, I get 3 matches. but there are two matching same numbers. one 3, one 6 in both groups.