Help with excel formula or vba code

I have a problem with excel vba and formula.
I am hoping someone could help me please.
The problem is:
I have a column "A" which are random number from 0-220, another column "C" with the maximum number of 500 allowed and to be maintained. Now, if in column "B" (which can only allow maximum 200) i want to generate values such that: if value A is greater than 200 and value C is 500, value B should be 200 and the next value of C should be new value of A minus 200 minus 500.
Second scenario: If the next value A is less than 200 and value C is less than 500, then Value B should be new value of A plus (500-next value of C) provided its not more than 200. But if it is more than 200, then the remainder should be added to next value of B....and so on.

I hope i am clear enough for any assistance please.

I don't mind to use formula or vba code, anyone that feels appropriate for the problem.

Thank you in anticipation.