MS Excel: Sumproduct only visible rows (use sumproduct with subtotal(9,array))

Pretty straightforward.

I want to use a SUMPRODUCT but only for visible rows.

I've tried =SUMPRODUCT(A2:A10, SUBTOTAL(9,B2:B10)) ... didn't work, even as an array formula.

I'm probably missing something obvious but ... why doesn't this work? How can I get this to work?


for doing that, use the formula:

=SUMPRODUCT(A2:A10,SUBTOTAL(9,OFFSET(B2:B10,ROW(B2:B10)-MIN(ROW(B2:B10)),0,1)))

enter image description here

As said in comments: keep in mind that SUBTOTAL does not work with manually hidden rows. Only rows which are hidden due to a "filter" will be skipped in the calculation.

EDIT
Thanks to XOR LX: If increasing the parameter of SUBTOTAL by 100 it will also work with manually hidden rows. The formula then would be:

=SUMPRODUCT(A2:A10,SUBTOTAL(109,OFFSET(B2:B10,ROW(B2:B10)-MIN(ROW(B2:B10)),0,1)))