Data start at M12
=INDEX(M12:M260,MATCH(1,INDEX(SUBTOTAL(2,OFFSET(M11,ROW(M1:M260),)),),))-INDEX(M12:M260,MATCH(1,INDEX(1/SUBTOTAL(2,OFFSET(M11,ROW(M1:M260),)),)))
=INDEX(M12:M260;EQUIV(1;INDEX(SOUS.TOTAL(2;DECALER(M11;LIGNE(M1:M260); )); ); ))-INDEX(M12:M260;EQUIV(1;INDEX(1/SOUS.TOTAL(2;DECALER(M11;LIGNE(M1:M260); )); )))