Basenji said:
I have the following formula,
{=SUMPRODUCT(--(A5:A1000>=1/1/2010),
--(A5:A1000<=1/31/2010),--(E5:E1000)="Smith")},
but am getting a value error. What am I missing?
The #VALUE error is caused by the incorrect placement of parentheses in the
last argument. But your formula will still have unexpected results.
At a minimum, you should write:
=SUMPRODUCT(--(A5:A1000>=--"1/1/2010"),
--(A5:A1000<=--"1/31/2010"),--(E5:E1000="Smith"))
This assumes that the dates in A5:A1000 are bona fide date numbers, not
text. The syntax --"1/1/2010" converts the date string to a date number;
otherwise, you are computing 1 divided by 1 divided by 2010. Also note the
placement of parentheses in the last argument.
Although that might work for you, it depends on your Regional and Language
settings. It would be better to write:
=SUMPRODUCT(--(A5:A1000>=DATE(2010,1,1)),
--(A5:A1000<=DATE(2010,1,31),--(E5:E1000="Smith"))
However, that still requires that you customize 12 different formulas. For
a more robust design, put the dates 1/1/2010, 2/1/2010 etc into a column, say
B1:B12, formatted with the Custom format "mmm" without quotes. Then in a
parallel column, say C1:C12, put the following formula into C1 and copy down:
=SUMPRODUCT(--(MONTH(A5:A1000)=MONTH(B1),
--(E5:E1000="Smith"))
or more simply:
=SUMPRODUCT((MONTH(A5:A1000)=MONTH(C1)
*(E5:E1000="Smith"))
This assumes that the dates in A5:A1000 are all in the same year, or at
least one 12-month period, as you stipulated originally.
----- original message -----