It works without the +1 =MOD(SUMPRODUCT(SUBTOTAL(3,OFFSET($A$2,ROW($A$2:$A 2)-ROW($A$2),,1)),--($A$1:$A1<>$A$2:$A2)),2)

Thanks for your help!