# Comparing two range of cells to find out the number of matches

I try to find 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 numbers of matches. The cells may have repetitions ( e.g, 1,2,2,2,3). Thanks.

Shortly, if we consider two range cells as two groups, I need a formula to show the number of matches. Numbers may not be in an order, there can be repetitions.

Edit:

I found this formula but it doesn't do the job in this task. =SUMPRODUCT(COUNTIF(A1:E1,A2:E2))

Example1: {1,1,1,1,1} and {1,1,1,1,1} here the number of matches should be 5. Example2: {1,2,4,5,6} and {1,2,2,4,5} here the number of matches should 4. And above formula doesn't give the correct results.

I assume you can use `Row 3` and `Column F`.
In cell `A3` use `=A1=A2` this will give you a value of `TRUE` if `A1` matches `A2`, repeat for `B3`through `E3`. Then in `Cell F3` use `=COUNTIF(A3:E3;"TRUE")`
This will give you the number of cells where the value in `Row 1` matches that in `Row 2`