Thread: SUMIF and Dates
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Roger Govier
 
Posts: n/a
Default SUMIF and Dates

Hi Bob

Many thanks for picking up on my typos. Dashed off in much haste before
going out. It should have read

=SUMPRODUCT(--(MONTH(Sheet1!$B$2:$B$100)<=MONTH(B$1)),Sheet1!$C$ 2:$C$100)

Whilst I agree it doesn't account for year, the blank dates have blank
values as well, so would make no difference to the sum.

Judging by the OP's expected result, he wanted cumulative data not
individual months data, and it did not seem to be split by Office, hence the
addition on the extra test as per my second formula doesn't seem to be
required.
(That formula also had the typos and should have read as follows
=SUMPRODUCT(--(MONTH(Sheet1!$B$2:$B$100)<=MONTH(B$1)),(Sheet1!$A $2:$A$100=$A2),Sheet1!$C$2:$C$100)

I think to meet the OP's requirement, the addition of a less than in your
formula, and the omission of the test for column A will give the desired
result (as posted), and would allow for different years.

=SUMPRODUCT(--(Sheet1!$B$2:$B$10-DAY(Sheet1!$B$2:$B$10)+1<=B$1-DAY(B$1)+1),Sheet1!$C$2:$C$10)


Regards

Roger Govier


Bob Phillips wrote:
Hi Roger,

A few typos in there, but more interestingly, it doesn't account the year,
and blanks would count as January as well. You could do it in one test as I
did the other day like this

=SUMPRODUCT(--(Sheet1!$B$2:$B$10-DAY(Sheet1!$B$2:$B$10)+1=B$1-DAY(B$1)+1),--
(Sheet1!$A$2:$A$10=$A2),Sheet1!$C$2:$C$10)