I believe there to be a logical error in your formulas. You make sums of the columns C,D and E and you use these totals in your IF-statement, but then again you try to something cumulative. Point is, I have it hard to understand what you try to accomplish.
Would it make sense to have like a starting balance.
Then Remain balance is starting balance + accumulated credits minus accumulated withdrawals?