Hi! I have this extremely big list of material that contains 10000-30000 positions -(COLUMN A) next to it is quantity in pieces (COLUMN B) values vary between 0 and hundred of thousands (these are also MAX VALUES). I need to automatically distribute each position of MATERIAL QUANTITIES over ORDER NUMBERS with different quantities of (various ) products so that the result is given as INTEGER number AND the SUM of all results doesnt exceed MAX value of each material quantity, there is no REST (or the rest is minimal), if the max value is reached sooner than end of orders-fields are populated with 0 , and the list of materials, quantities, product quantities vary over time. I work in a large warehouse, and need to solve this. Decimal numbers dont work as the materials are given as pieces, so there are no halves, quarters etc. I don't know where to even begin as my knowledge in Excel is pretty basic. Please help with some magic FORMULA or VBA code, I work on EXCEL 365 , thank you very much for your time and help!