I don't think nested ifs is the effective way to deal with tha. Note that even with no-holiday period (task 1) the calculations dont sum to total cost (column F).
My proposition is to use the list of all days in a holiday period and use networkdays function. So having a list Dec 12 till Jan 15 in AV1:AV35 a formula in H7 (and copy down and right) could read:
May look as long one but it consists of checking if a beginning of a week is in holiday period:
(could be done also by simple testing two limiting dates, like
So if it is 0, we have result 0 and if not the main part:
The last part
is (I hope) obvious. It's our daily spending (CostToComplete/NumberOfWorkingDays)
it is the last day of given week (start of week+5) or last day of work (we had to add 1 here, because otherwise task starting and ending the same day would be 0 day long), whichever of these two days is earlier
and we take also a later date of the two (start date and beginning of given week
the difference between the two is the number of days worked in given week. But note that before startday or after endday we will have wrong results, namely: negative numbers. So we take only positive values using
Check it out but first check your dates in E9 you have Jan 23rd 5PM. It would lead to wrong result in X9 (last week). The same mistake is in E10, but as it's the date during weekend makes no effect on results.
PS. As you are using excel 365 the date range containing holidays could be dynamically created but I think it would make a formula even harder to read.
Bookmarks