I have reproduced your sheet and have the values 10 to 21 in A5:A13. New Contracts are in B, Price is in C and Total Earned in D. I have the variable $5.00 entered in cell E3. Row 4 is blank. The formulas are as follows:
D5 =C5*A5.
E5 =D5-$E$3.
F5 =IF(SUM($E$4:E5)-COUNT($F$4:F4)*$E$3>=5,SUM($E$4:E5)-SUM($F$4:F4),"").
G5 =IF(SUM(F5)>0,-$E$3,"").
H5 =IF(SUM(F5)>0,SUM($F$4:G5),"").
Copy them all down to row 13.
The produce the correct figures for the data you have supplied.
Thank you again. It is almost what I was looking for. If we can again, let me explain using this example.
Lets say we have tokens: and every time we get 5 more (since the new token costs $5(which is a variable)) we can buy another token, we then add that new token to the 10 (current) (now 11 (10+1 the new token)) and multiply out again. Each time calculating the NEW amount of tokens per the formulas:
10 Tokens x $.5 = $5 ( we can now buy 1 new token) - 0 left over
11 Tokens x .5 x $5.5 (can buy 1 more token) 0.5 left over
12 Tokens x .5 x $6.0 (can buy 1 more token) 1.0 left over PLUS the 0.5 from above = 1.5 in the bank
13 Tokens x .5 x $6.5 (can buy 1 more token) 1.5 left over PLUS the 1.5 from above = 3 in the bank
14 Tokens x .5 x $7.0 (can buy 1 more token) 2.0 left over PLUS the 3.0 from above = 5 in the bank (now can buy an additional token @ the $5 (variable) = 0.0 in the bank
15 (
skipped 15 since we bought 2 tokens last round) (went from 14 to 16)
16 Tokens x .5 x $8.0 (can buy 1 more token) 3.0 left over PLUS the 0.0 from above = 3 in the bank
17 Tokens x .5 x $8.5 (can buy 1 more token) 3.5 left over PLUS the 3 from above = 6 in the bank (now can buy
1 additional token) bank (6-5) = 1 in the bank
19 Tokens x .5 x $9.5 (can buy 1 more token) 4.5 left over PLUS the 1 from above = 5.5 in the bank (now can buy
1 additional token) bank (5.5-5) = 0.5 in the bank
21 Tokens x .5 x $10.5 (can buy
2 more tokens) (5+5=10-0.5)=0.5 left over PLUS the 0.5 from above = 1.0 in the bank
23 Tokens x .5 x $11.5 (can buy
2 more tokens) 1.5 left over PLUS the 1 from above = 2.5 in the bank
25 Tokens x .5 x $12.5 (can buy
2 more tokens) 2.5 left over PLUS the 2.5 from above = 5.0 in the bank(now can buy
1 additional token) bank (5.0-5) = 0.0 in the bank
28 Tokens x .5 x $14 (can buy
2 more tokens) 4.00 left over PLUS the 0 from above = 4.0 in the bank
30 Tokens x .5 x $15 (can buy
3 more tokens) 0.0 left over PLUS the 1 from above = 1.0 in the bank
33 Tokens x .5 x $16.5 (can buy
3 more tokens) 1.5 left over PLUS the 1 from above = 2.5 in the bank
34 Tokens x .5 x $17.0 (can buy
3 more tokens) 2.5 left over PLUS the 2.5 from above = 5.0 in the bank(now can buy
1 additional token) bank (5.0-5) = 0.0 in the bank
37 Tokens x .5 x $18.5 (can buy
3 more tokens) 3.5 left over PLUS the 0.0 from above = 3.0 in the bank
40 Tokens x .5 x $20.0 (can buy
4more tokens) 3.5 left over PLUS the 0.0 from above = 3.5 in the bank
44 etc..............