Q:

Excel - autofill formula horizontally with cell number increment

I have the following problem. I want to copy this formula =SUMPRODUCT(--($C3:$Q3=C4:Q4)) ,which is in cell C13, to the adjacent cells (D13, E13, F13 etc.), but I want $C3:$Q3 to become $C4:$Q4. (basically =SUMPRODUCT(--($C3:$Q3=C4:Q4)) ====> =SUMPRODUCT(--($C4:$Q4=C4:Q4)) and so on). Dragging horizontally doesn't help, since autofill increments the rows and not the column number. 
I tried with OFFSET, but as far as I understand, it references the data and not the formulas. Any help would be appreciated. Thanks in advance. 

A:

In C13 put
=SUMPRODUCT(--(OFFSET($C$3:$Q$3,SUM(COLUMN(C13)-COLUMN($C$13)),,,)=$C$4:$Q$4))

Then drag this across columns. 
Note: 
1) This assumes $C$4:$Q$4 is a fixed range to compare against as it remains the same in your given example
2) That you don't mind the fact that the formula in column D will self reference for comparison
You could also just enclose in Index instead.
=SUMPRODUCT(--(INDEX(OFFSET($C$3:$Q$3,COLUMN(C13)-COLUMN($C$13),,,),0,0)=$C$4:$Q$4))

Example:

Edit:
Based on share workbook where need to drag across columns and down rows to compare 64 * 64 matrix element wise (where each element is a row in the source array)
In C71 put the following and drag down and across to BM133:
=SUMPRODUCT(--(INDEX($C$2:$W$64,MATCH($B71,$B$2:$B$64,0),0)=INDEX($C$2:$W$64,MATCH(C$70,$B$2:$B$64,0),0)))

Result:

With column R test on gender being different added in C71 put the following and drag down and across to BM133:
=IF(INDEX($C$2:$W$64,MATCH($B71,$B$2:$B$64,0),16)<>INDEX($C$2:$W$64,MATCH(C$70,$B$2:$B$64,0),16),SUMPRODUCT(--(INDEX($C$2:$W$64,MATCH($B71,$B$2:$B$64,0),0)=INDEX($C$2:$W$64,MATCH(C$70,$B$2:$B$64,0),0))),"")

