View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default Sumproduct with OR

This seems to work:

=SUMPRODUCT(--((ISNUMBER(SEARCH("A",RangeA)))+(ISNUMBER(SEARCH(" B",RangeA)))+(ISNUMBER(SEARCH("C",RangeA)))=1) ,--(RangeB="Baltimore"))

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"andy62" wrote in message
...
I'm almost there but one complication. I realized my cells in RangeA do
not
= "A" or "B" or "C", they contain "A" and/or "B" and/or "C". I got past
that
with the trusty ISNUMBER(SEARCH("A",RangeA)), but those plus signs between
factors are making me count multiple occurences. My SUMPRODUCT result is
looking like 2,2,1,0,3,2 etc. when, instead, I want it to produce a "1"
when
the cell contains at least one match and 0 if no matches. Can this be
tweaked of do I need a whole new approach? TIA

"Sandy Mann" wrote:

In SUMPRODUCT() formulas multiplication acts like an AND() statement and
addition acts like an OR() statement so try:

=SUMPRODUCT(((RangeA="A")+(RangeA="B")+(RangeA="C" ),--(RangeB="Baltimore))

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"andy62" wrote in message
...
I'm sure there's a way to simplify this but not seeing it in any of the
previous answers. I have a SUMPRODUCT function where the first factor
has
a
lot of acceptable conditions, and I want to combine them somehow:

=SUMPRODUCT(--(RangeA="A"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="C"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="G"),--(RangeB="Baltimore))
. . .

The only thing changing is the condition in the first factor. rather
than
repeat the whole function and add the results together, ideally I could
recode this mess somehow as "=SUMPRODUCT(--(RangeA=OR("A","C","G", . .
.),--(RangeB="Baltimore")). Any ideas? TIA