Start with C34:
=IF(C$32<=$B5,0,MIN($F5,(C$32-$B5)*$E5))
and copy down
of course for row 34 could be easier, because B5 is 0, but as we copy it down, we need reference to the beginning of each range
Note that mixed addressing is used (either row relative column absolute or vice versa).
if we copy it right we will notice that the amaunts already used from given pot shall be substracted.
so formula for D34 shall look like:
=IF(D$32<=$B5,0,MIN($F5,(D$32-$B5)*$E5)-SUM($C34:C34))
it can be copied down and to right to the end of table
if the range B34:B37 is empty we can use unified version of the formula - for C34:
=IF(C$32<=$B5,0,MIN($F5,(C$32-$B5)*$E5)-SUM($B34:B34))
so just this one and copy both down and right - it is used in the attachment.
Bookmarks