At a first exploration this looks difficult to solve and I don't know whether I can help.
So a few questions:
- What version of Excel are you using?
- Would a macro be OK?
- If not a macro, would a User Defined Function be OK? (It uses a macro, but you use it just like a formula.)
- Is the worksheet function LAMBDA available to you?
And another:
If a new line was placed at the bottom of the right hand table being:
Code QTY
113S 1
what would be the
Place?
For others, it looks like the table on the left is a stock inventory, with the items being
Code, the
Place being a location/bin and
QTY being the count of those items in the bin.
The table on the right is the demand for stock and the OP wants to know which bin he can fetch the entire stock from to fulfil one row's demand (no picking items from 2 bins to fulfil the demand on one row).
It looks like there's a preference to take stock from the higher rows of the inventory first, and the demand table on the right seems to be processed top down too.