使用 Excel 上的公式计算 EndDate
Calculate EndDate using a formula on Excel
所以我正在尝试编写一个公式,让我知道一个项目的 endDateTime 只知道两件事:
- startDate;
- How many hours it will take to finish the project;
这里的问题是我不能只使用 vba 普通的 excel 公式。
我尝试使用 =WORKDAY.INTL(date,days,"workingDaysPattern",holidaysTable) 但我的问题是其中一个前提是 workingTimePerDay 也是一个变量。
Example:
startDateTime => 29 November 2016 at 10:00 and it will take 125 hours to complete.
Every Monday i have 2 hours to work;
Tuesday 3 hours;
Wednesday 8 hours;
Thursday 10 hours;
Friday 5 hours;
Saturday 12 hours;
Sunday 0 hours;
Giving a total of 40 hours.
Ok, i could calculate average and say that it will take 3 weeks and 0,125 of a week. Then i just have to sum it up until i make the expected result, but... since i don't have a "while" or any kind of cycle i don't know how to get there.
Also because i have to respect the holidays so i cannot just build an array formula like:
{=SUM(CHOOSE(WEEKDAY(ROW(INDIRECT(date1&":"&date2))),1,2,3,4,5,6,7))}
有什么想法吗?
好的。我知道了。以防万一有人需要这个。 (我对此表示怀疑)
我们知道的事情:
- 开始日期; 需要任务工作时间; 每天工作时间; 假期表
首先我们创建一个 table 的工作日 WEEKDAY function 。因为我们知道每周的总工作时间(求和WorkingHoursPerDay),计算总工作周数(超过):
ExceededWorkingWeeks = CEILING(TaskWorkingHoursNeeded/WorkingHoursPerWeek;0)
其次,如果就这样,在多少天(超过):
ExceededWorkingDays = exceededWorkingWeeks / countDaysWhereExistWorkingHours
三、在多少小时内(超过):
ExceededWorkingHours = ExceededWorkingWeeks * WorkingHoursPerWeek
所以,如果我们使用 ExceededWorkingDays,现在我们可以计算超出的结束日期,不要忘记我们工作的假期和一周中的第几天 (Resource) :
ExceededEndDate = WORKDAY.INTL(StartDate, ExceededWorkingDays, "patternWorkingWeekDays", HolidaysTable)
现在是“丑陋”的部分。很多如果和其他的,我们就完成了。
对于从 0 到 6 的 7 个 value 位置,我们首先计算天减去 value 天到 ExceededEndDate。然后要知道这一天是否重要,我们计算这是否是我们 patternWorkingWeekDays 的工作日而不是假期:
CheckWorkDay = NETWORKDAYS.INTL(ValueNewDate;ValueNewDate;"patternWorkingWeekDays";HolidaysTable)
如果returns1表示这个工作日的小时数要减去ExceededWorkingHours。使用“索引对齐”计算工作日:
ValueNewWeekDay = 7-MOD(ABS(value+(7-WEEKDAY(ExceededEndDate)));7)
使用这个 ValueNewWeekDay 索引到 table 我的工作日我可以知道我必须减去多少小时 CurrentExceededWorkingHours.
对于每个工作日,而不是节假日,将工作时间减去 CurrentExceededWorkingHours,直到得到 CurrentExceededWorkingHours < TaskWorkingHoursNeeded
。当然,如果 ValueNewDate 低于 StartDate.
,则检查每个 value
如客户所愿,我们可以将所有这些公式放在一个单元格中。
RESUME:
Real end date is calculated by subtracting for a week (7 days) the exceeded hours.
所以我正在尝试编写一个公式,让我知道一个项目的 endDateTime 只知道两件事:
- startDate;
- How many hours it will take to finish the project;
这里的问题是我不能只使用 vba 普通的 excel 公式。
我尝试使用 =WORKDAY.INTL(date,days,"workingDaysPattern",holidaysTable) 但我的问题是其中一个前提是 workingTimePerDay 也是一个变量。
Example:
startDateTime => 29 November 2016 at 10:00 and it will take 125 hours to complete.
Every Monday i have 2 hours to work;
Tuesday 3 hours;
Wednesday 8 hours;
Thursday 10 hours;
Friday 5 hours;
Saturday 12 hours;
Sunday 0 hours;
Giving a total of 40 hours. Ok, i could calculate average and say that it will take 3 weeks and 0,125 of a week. Then i just have to sum it up until i make the expected result, but... since i don't have a "while" or any kind of cycle i don't know how to get there. Also because i have to respect the holidays so i cannot just build an array formula like:
{=SUM(CHOOSE(WEEKDAY(ROW(INDIRECT(date1&":"&date2))),1,2,3,4,5,6,7))}
有什么想法吗?
好的。我知道了。以防万一有人需要这个。 (我对此表示怀疑) 我们知道的事情:
- 开始日期; 需要任务工作时间; 每天工作时间; 假期表
首先我们创建一个 table 的工作日 WEEKDAY function 。因为我们知道每周的总工作时间(求和WorkingHoursPerDay),计算总工作周数(超过):
ExceededWorkingWeeks = CEILING(TaskWorkingHoursNeeded/WorkingHoursPerWeek;0)
其次,如果就这样,在多少天(超过):
ExceededWorkingDays = exceededWorkingWeeks / countDaysWhereExistWorkingHours
三、在多少小时内(超过):
ExceededWorkingHours = ExceededWorkingWeeks * WorkingHoursPerWeek
所以,如果我们使用 ExceededWorkingDays,现在我们可以计算超出的结束日期,不要忘记我们工作的假期和一周中的第几天 (Resource) :
ExceededEndDate = WORKDAY.INTL(StartDate, ExceededWorkingDays, "patternWorkingWeekDays", HolidaysTable)
现在是“丑陋”的部分。很多如果和其他的,我们就完成了。
对于从 0 到 6 的 7 个 value 位置,我们首先计算天减去 value 天到 ExceededEndDate。然后要知道这一天是否重要,我们计算这是否是我们 patternWorkingWeekDays 的工作日而不是假期:
CheckWorkDay = NETWORKDAYS.INTL(ValueNewDate;ValueNewDate;"patternWorkingWeekDays";HolidaysTable)
如果returns1表示这个工作日的小时数要减去ExceededWorkingHours。使用“索引对齐”计算工作日:
ValueNewWeekDay = 7-MOD(ABS(value+(7-WEEKDAY(ExceededEndDate)));7)
使用这个 ValueNewWeekDay 索引到 table 我的工作日我可以知道我必须减去多少小时 CurrentExceededWorkingHours.
对于每个工作日,而不是节假日,将工作时间减去 CurrentExceededWorkingHours,直到得到 CurrentExceededWorkingHours < TaskWorkingHoursNeeded
。当然,如果 ValueNewDate 低于 StartDate.
如客户所愿,我们可以将所有这些公式放在一个单元格中。
RESUME:
Real end date is calculated by subtracting for a week (7 days) the exceeded hours.