View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
EvolBob EvolBob is offline
external usenet poster
 
Posts: 16
Default Can I use OR in SUMIF?

Long intuitive version..

=SUMPRODUCT(SUMIF(B2:B7, {"Apple","Orange"},C2:C7))

...slightly shorter but less intuitive.

=SUMPRODUCT((B2:B7={"Apple","Orange"})*C2:C7)

Hard coding the sum up values should be avoided.
You could put them into a cell range, in this case J1 and K1, one variable per cell.

=SUMPRODUCT((B2:B7=J1:K1)*C2:C7)

Use J1:J2 and it wont work, the range size having to be the same and all that, but for some reason it don't apply if it goes in another direction, or for Sumif - go figure.

=SUMPRODUCT(SUMIF(B2:B17,J1:J2,C2:C7))


Regards
Robert McCurdy

"iampritzy" wrote in message ...
rFor example: SUMIF(B2:B7, "Apple OR Orange", C2:C7) If it's an apple or an
orange, sum their values in column c.
It does not work. Can anyone help?