Fantastic challenge. I actually struggled with this one and I feel there are better ways to do this.
Here is my solution using a macro. Looking now at all the nice Running Total solutions, mine looks like a monster. Also felt a bit like adding some checks to the workflow so I am checking that the total number of credits/debits against the account equals to the total number of actual transactions per account.