Hi
I wonder if we have the complete picture here?
Clearly, there must be some data in your table for items bought, as the
math doesn't support the amount remaining in each case.
I was wondering whether what you really wanted, was the amount remaining
for each items, as opposed to seeing the last sold value for the item.
If so then your summary sheet could keep a running total for you for
each product.
Assume the numbers bought are in column J
On Sheet2 set up some headers in A1

1 of
Product Bought Sold Remaining
IN A2 onwards enter your list of product names
In B2 enter
=IF($A2="","",SUMPRODUCT((Sheet1!$A$2:$A$100=$A2)*(Sheet1!$J$2:$J$100)))
In C2 enter
=IF($A2="","",SUMPRODUCT((Sheet1!$A$2:$A$100=$A2)*(Sheet1!$K$2:$K$100)))
In D2 enter
=B2-C2
Copy B2

2 down the page as far as your list of products extends
Change the length of the ranges (and the column Identifier for Bought)
to suit your data table, but do ensure that the ranges are of equal
length.
I may be jumping to the wrong conclusion here, and if I am I apologise.