View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme[_3_] Bernard Liengme[_3_] is offline
external usenet poster
 
Posts: 1,104
Default SumIf statement: incrementing

I put dates in column G and numbers to sum in column H
In A5 I have the "current date"
I used this formula
=SUMIF(G1:G31,""&A5-IF(DAY(A5)<8,8,IF(DAY(A5)<14,16,24)),H1:H31)
to try to duplicate your three options.

DAY(A5) returns the calendar day and I check if was less than 14, less than
14 to compute how many days to subtract from A5.
You will need to work on it - 8 days in a week had me confused
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Kesbutler" wrote in message
...
I have the following formula:
=SUMIF('weekly dates'!A1:AZ1,""&A5,Details!L7:BK7)

Weekly dates is a static sheet, &A5 is the current date and Details!L7:BK7
are cells that are calculated weekly on a sheet different from where this
formula is used.

There are 4 weeks per period and this report is done weekly. I need the
SUMIF to be just as it is for week 1, but for week 2, I need to include
weeks
1&2, week 3 to include 1-3 and week 4 to include 1-4. Then it starts over
after week 4. I can do by changing the formula weekly in the following
way.
=SUMIF('weekly dates'!A1:AZ1,""&A5-8,Details!L7:BK7) week2
=SUMIF('weekly dates'!A1:AZ1,""&A5-16,Details!L7:BK7) week3
=SUMIF('weekly dates'!A1:AZ1,""&A5-24,Details!L7:BK7) week4

I know there has to be a cleaner and more correct way of doing this. Any
ideas?