Hi,

I ended up with quite long formula (partialy because your input and outbut are in a sense rotated/transposed), but it seems to work. In E17 and copy down and right:

=IF(E$15>$D17,"",E$14-SUMPRODUCT(E$5:E$13,(OFFSET($D$5:$D$13,0,MATCH($D17,$E$15:$O$15,0))="SALE")+(OFFSET($D$5:$D$13,0,MATCH($D17,$E$15:$O$15,0))="")))

if it really works (please check) - you could add IFERROR at the beginning to avoid #N/A! in rows starting 31-03-2012
wher you have no data in columns on input side.