Hi all,

I need help with a formula. Essentially I manufacture three products - A, B and C. Once I have manufactured 25,000 tons of product it can be shipped. Within the shipment I want to take first available Product A then product B and then Product C. Hopefully the attached Excel file will make the problem a little clearer. Formulas required for the shaded area.

To add a further complication I want to have the flexibility to change the order in which to ship the product for example first to Product B then Product A and then Product C. (Perhaps this can be achieved with a VLOOKUP or MATCH?).

Happy to use code if that is the most elegant solution.

Many thanks in advance,

Andrew