View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Sumproduct not working

wrote:
This returns 0, looking for 2.
=SUMPRODUCT(--(B2:B6="*4PM-6PM Start*")*(A2:A6<""))

As a test these return 5 so the "*wild card*" is not an issue.
=COUNTIF(B2:B6,"*4PM-6PM Start*")
=COUNTIF(B2:B6,"*4PM-6PM*")


The asterisk never works as a wild-card with any comparison operator. For
example, IF(B2="*4PM-6PM Start*",...) does not do what you might expect.

Wild-card characters work only in specified functions, like COUNTIF.

If you have Excel 2007 or later (please specify in future questions) and
your intent is to count when both conditions are met, you can do:

=COUNTIFS(B2:B6="*4PM-6PM Start*",A2:A6,"<")

Note the "S" at then of COUNTIFS.

Caveat: The condition "<" might not work exactly A2:A6<"" above, IIRC.
Experiment to be sure that it counts all the instances you want, and it does
not count instances you do not want.

Alternatively (works in all Excel versions):

=SUMPRODUCT(ISNUMBER(SEARCH("4PM-6PM Start",B2:B6))*(A2:A6<""))

Caveat: Test that carefully. I did not.

Note: You do not need double-negation ("--") if you multiply conditions.
Any arithmetic operation is sufficient to change TRUE and FALSE into 1 and
0.