View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Joe User[_2_] Joe User[_2_] is offline
external usenet poster
 
Posts: 905
Default SUMPRODUCT with conditional OR

"Struggling in Sheffield" wrote:
=IF(AK1014="","",
SUMPRODUCT(--(($G$3:$G$1002=4)+
($H$3:$H$1002=4)), --($G$3:$G$1002<""),
--($H$3:$H$1002<""),AK3:AK1002))

This works fine except when both values are 4 or
greater, as it then sums the value in column AK twice.


That is exactly what happens. The problem is that ($G$3...)+($H$3...)
evaluates to 2 when both conditions are true, resulting in multiplying by 2
instead of 1 (TRUE).

Use one of the following, whichever is easier for you to maintain. They are
equivalent. The latter avoids using "--":

=IF(AK1014="","",
SUMPRODUCT(
--(($G$3:$G$1002=4)+($H$3:$H$1002=4)<0),
--($G$3:$G$1002<""), --($H$3:$H$1002<""),
AK3:AK1002))

---or---

=IF(AK1014="","",
SUMPRODUCT(
(($G$3:$G$1002=4)+($H$3:$H$1002=4)<0)
*($G$3:$G$1002<"")*($H$3:$H$1002<""), AK3:AK1002))


----- original message -----

"Struggling in Sheffield" wrote:
Hi chaps,
Am using the following formula to check two columns of numbers (G3-G1002 &
H3-H1002). If the value in either column is 4 or greater, I'm summing a
corresponding value in column AK (AK3-AK1002):

=IF(AK1014="","",SUMPRODUCT(--(($G$3:$G$1002=4)+($H$3:$H$1002=4)),--($G$3:$G$1002<""),--($H$3:$H$1002<""),AK3:AK1002))

This works fine except when both values are 4 or greater, as it then sums
the value in column AK twice.

Would appreciate any help to tweak the formula into submission.
Thanks for looking.