View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John C[_2_] John C[_2_] is offline
external usenet poster
 
Posts: 1,358
Default Summing multiple rows if criteria

I have your A range in column A, your B range in column B, and your Qty in
column C, with Total in column D, modify as necessary:
in D2, type the following, then fill down as far as needed.

=IF(SUMPRODUCT(--(A$2:A2=A2),--(B$2:B2=B2),(C$2:C2))=C2,"",IF(SUMPRODUCT(--(A$2:A2=A2),--(B$2:B2=B2),(C$2:C2))=SUMPRODUCT(--(A$2:A$8=A2),--(B$2:B$8=B2),(C$2:C$8)),SUMPRODUCT(--(A$2:A$8=A2),--(B$2:B$8=B2),(C$2:C$8)),""))

Hope this helps.

--
John C


"bsl" wrote:

Here's my example:

A B Qty Total
d y 2
d z 3
e x 4
e x 10
e x 11 25
e y 5
f x 1

I want to add the numbers in the Quantity Field, but only where you have
duplicates. For example, in this case, QTY 4, 10, 15 would be added in a new
column "Total" as Column B's "x" was the same for every Column A's e. No
other additions would take place. The database has 5,000 rows and sometimes
there are two duplicates, but other times there are 10 duplicates, so I
haven't been able to do a sum product. I tried =IF(B4=B5,SUMPRODUCT(D4:D5),
0) but this only added two rows, not the 3 rows together.

Many thanks!