For an example, suppose I have 10 columns and 10 rows, and in whitch, a number.
I want to compare each row with all the others, looking for how many cells in the same row have the same value.

To compare rows, in this example, I used =SUMPRODUCT(--(A1:J1=A2:J2)) in row 1.
dragging the formula down, I will compare each row with the row below.

Now, I want to compare row 1 with rows 3,4...10 in line 1. I would have to lock A$1:J$1 in the formula, an then drag to te right, and there's my issue.
How do i change the row instead of the column when dragging the formula horizontally? Another issue, to make things work, to drag down the whole row of formulas, I would have to unlock the A$!:J$1. But it is locked in the 9 cells I compare the first row values with.

I did it by hand in the attached example, but would be unthinkable to do so in my original file with 870 rows.

Any Ideas? Is there a way to lock/unlock a bunch of formulas in different cells at the same time?

I attached an example file of what i want to do. Any Ideas?
Thanks in advance!test comparison.xlsx