with D2 the active cell, you can apply the following rule (and apply to D2:BR2)
Formula:
=IF(D2,($B2-SUMIFS($C2:C2,$C$1:C$1,"Buyer*",$C2:C2,"<="&$B2,$C2:C2,">="&D2))>=D2)
set format as required
the above will find items left to right, in that order, until such time as the stock requirement is filled, or there are no other options to complete it.
edit: if you end up with scenarios where you have stock of say 150, and available values of 144, 72 and 78 -- the above will format 144, rather than 72 & 78
so, if it transpires that you want the 'optimal' combination (i.e. combination closest to total) then things get a whole lot more complicated - to point of not really being feasible (in XL)
Bookmarks