I'm compiling a spreadsheet of horse racing results and have encountered a problem.

I have 3 Columns.

"A" states whether or not a bet is valid, if it is, a 1 will appear in the column, if it isn't a 0 will appear instead.

If "A" is valid and the bet wins then I have a positive change column which I have called "B", once again, a positive change is indicated by a 1 and either no change at all or a negative change will produce a 0.

"C" is the reverse of "B", if I have a valid bet but it loses, it will produce a 1, etc etc etc.

Now I need to write a column "D" that will tot up the winning bets until I get a losing one at which point it will revert to 0.

Then I will need a column "E" that will tot up the losing bets until I get a winning one at which point it will revert to 0.

Finally, I need to know how to find the highest number in "D" which will be shown in column "F" and also the reverse, ie how to find the highest number in "E" that will be shown in column "G".

Can anyone help?