I have a Sum if formula that works but it is part of a column that currently has subtotals and many rows that subtotal a portion of those totals. The formula I wrote is great because it uses a reference column to add only the rows I need. Is there a way to transform this into subtotal? This formula was written in AJ942:

{=SUM(IF(E3:OFFSET(E942,-1,0)=E942,AJ3:OFFSET(AJ942,-1,0)))}

I have tried this and it did not work.
{=SUBTOTAL(9,(IF(E3:OFFSET(E942,-1,0)=E942,AJ3:OFFSET(AJ942,-1,0))))}

I have seen other posts mentioning sumproduct but this does not work for me.

Thank you!