Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Can I use OR in SUMIF?

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Can I use OR in SUMIF?

=SUMPRODUCT(--(((B2:B7="apple")+(B2:B7="orange"))0),C2:C7)


"iampritzy" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Can I use OR in SUMIF?

As long as the conditions are disjoint (they can't both be satisfied as the
same time), just add the results of multiple sumif's:
=sumif(b2:b7,"Apple",c2:c7)+sumif(b2:b7,"Orange",c 2:c7)

"iampritzy" wrote:

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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
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?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Can I use OR in SUMIF?

I tried all solutions you guys provided. Thank you all.

"EvolBob" wrote:

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?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can I use OR in SUMIF?


surely simpler.....

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


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=526488

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SumIf MadWoman Excel Discussion (Misc queries) 3 July 29th 08 10:21 PM
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" Harry Seymour Excel Worksheet Functions 9 June 12th 07 10:47 PM
Embedding a Sumif in a sumif C.Pflugrath Excel Worksheet Functions 5 August 31st 05 07:31 PM
nested sumif or sumif with two criteria dshigley Excel Worksheet Functions 5 April 5th 05 03:34 AM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM


All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"