Reputation: 5713
I got some trouble with the SUMIFS function in Excel (2010). I want to make a sum of my hours per week, so I need a SUMIF. This is an example:
In F5 (and whole column F) is this function:
=IF(OR(A6="",WEEKNUM(A6,2)<>WEEKNUM(A5,2)),SUMIFS(E$2:E6,G$2:G6,"="&G5),"")
summing all values from E at the end of each week.
I would like to get rid of the extra column G that I need now, and use the WEEKNUM function instead. Then the function in F5 would look something like this
=IF(OR(A6="",WEEKNUM(A6,2)<>WEEKNUM(A5,2)),SUMIFS(E$2:E6,WEEKNUM(A$2:A6),"="&WEEKNUM(A5)),"")
but this example isn't working.
Any ideas?
Upvotes: 0
Views: 2836
Reputation: 46341
You can't use any function to modify a range in SUMIFS.....and also I would say that WEEKNUM isn't best for this as you may get confusion between years; and also weeks at the start/end of the year may not have 7 days (because week 1 always starts on 1st Jan whatever the day of the week - according to how WEEKNUM works anyway). You can use WEEKDAY
function more easily, e.g. in F5
=IF(OR(A6="",A5-WEEKDAY(A5,3)<>A6-WEEKDAY(A6,3)),SUMIFS(E$2:E5,A$2:A5,">="&A5-WEEKDAY(A5,3)),"")
That uses WEEKDAY
to find the previous Monday and sums anything that is in the last week based on that - so this will work even through Dec/Jan
Upvotes: 1