Perhaps this UDF would help. It looks down the compareRange and if the entry in that column matches the compareValue, adds the sum of all entries on that row of the SumRange to the result and then looks at the next row.
For your example, if your product is in Column A and the demands are in B & C, =SumRangeIf(A:A,1616, B:C) and =SumRowsIf(A:A, 1617, B:C) would be the syntax.
Even if you don't call this as a spreadsheet function, it might be helpful writting the macro you want. About that macro, on which sheet is the Product and demand data you want to process (are there only two demand columns or is the column count variable) and where do you want the results?
Bookmarks