View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme Bernard Liengme is offline
external usenet poster
 
Posts: 4,393
Default Adding numerical values based on multiple values in another column

Why not just
=SUMPRODUCT((A1:A5="red")+(A1:A5="green"),B1:B5)
No need for "- -" since the addition operator will coerce logical values to
numeric
No need for "0" since 0 * anything = 0
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Peo Sjoblom" wrote in message
...
A couple of ways

=SUM(SUMIF(A2:A6,{"Red";"Green"},B2:B6))

or

=SUMPRODUCT(--((A2:A6="Red")+(A2:A6="Green")0),B2:B6)

both returns 57


--
Regards,

Peo Sjoblom



"Kazmaniac" wrote in message
...
Please help
I am trying to add numerical values in one column based on multiple
values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a value
of
red and green in column A. Thank you in advance for your help!