Looking at it again, it can be simplified:
=SUMPRODUCT(SUBTOTAL(9,OFFSET(D2,ROW(D2:D22)-ROW(D2),,1)),$B$2:$B$22)