Cartel1.xlsx

Hi there,

I would really appreciate your help. I need a formula that takes the total value on D7 (18 in the example attached), and allocates the stock from D10 to D27 with the conditions from C2 and C3 (so minimum 1 case and maximum 3 cases per store). Lastly, if the stock is not enough, the formula should priorities the ones with the high priority value from C10 to C27.
Many thanks for any help given
Cristian