Cause of with .doc I dont know what is the format but if D column is real date formated as dd.mmm.yy, try in F1:
=IF(OR(G1<>"",D1+E1=0),"",SUMPRODUCT(--(IF($D$1:$D$4+$E$1:$E$4<>0,IF($G$1:$G$4="",$D$1:$D$4+$E$1:$E$4,""),"")<=(D1+E1))))
...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
Drag down.
Bookmarks