I have an spreasheet that i am trying to create. Overall I have established quantities per item and I need a formula that will tell me how many pieces of the Item I should pick per line, Ex
Item A: 13 Pieces
Item B: 2 Pieces,

Inventory
Line 1 item a: 5 pcs
Line 2 Item a: 5 pcs
Line 3 Item a: 5 pcs
Line 4 item a: 5 pcs
Line 5: item b: 3 pcs

Basically the result for the formula i am looking for will tell me the items to be picked until budget is reached. line 1: 5 pcs, line 2: 5 pcs and line 3: 3 pcs. Line 4 should say: 0 pcs (budget already met), line 5:3 pieces.

I tried using a cumulative formula and if statement but did not work. any suggestions???

Thanks.