use this formula in H2 in sheet Sell:

=F2-SOMPRODUCT((Buy!$B$2:$B$30=$C2)*(Buy!$D$2:$D$30=$D2)*(Buy!$F$2:$F$30))