Here is a modification to the formula that can be pasted into E2 and that has been tested on the set up shown in the top screen shot (employee illness 1/13/17 - 1/17/17) and yields the expected 1 in E18:
Formula: copy to clipboard
=IF(SUM(INDIRECT(ADDRESS(MATCH(EDATE(SUMMARY!$B$4,-12),CALENDAR!$A$2:$A$1827,0)+1,4,2)):D2)<=40,0,IF(AND(C2="Employee Illness",OR(SUM(INDIRECT(ADDRESS(MATCH(EDATE(SUMMARY!$B$4,-12),CALENDAR!$A$2:$A$1827,0)+1,4,2)):D1)<40,C2<>C1)),1,0))
Let us know if you have any questions.