Deduct sold stock from the stock when 0 continue to next next cell with same SKU

aimer

New Member
Joined
Feb 18, 2015
Messages
1
Okay i have a question... Right now i am making my life quite horrible, because of it. Probably you all can relate to these "Excel challenges".

I am trying to create a small ERP system, but i am running in some issues with the stock list. Let me explain it a bit further:

Sheet 1: Product list: The product list has basic information about the products, like SKU, Name, Complete Stock, Average buying price
Sheet 2: Import orders: This sheet i wanna fill in all import orders on date, with Date, ordername. SKU, Bought stock, Buying Price, Total buying price
Sheet 3: Sales: A list with all the orders we have, these will be deducted from the stock on the second sheet so that we can keep the average buying price as correct as possible.

My issue happens on the second sheet. I would love to let the stock go to zero per order. So let's say:

We have 3 orders of Product 1:
1 - 500 pcs - 20 dollar - 10.000 dollar
2 - 800 pcs - 15 dollar - 12.000 dollar
3 - 150 pcs - 21 dollar - 3.150 dollar

In the beginning the average price will be 17,34 (1+2+3/total stock) but when the batch 1 is sold out the average price will change to 15,94 (2+3/total stock). But the big question is how can i deduct the sold amount from order 1 and from than continue to order 2 and so on. So when there are 500 pieces sold it will become 0 and than the rest of the sold pieces go to order 2 till that one becomes 0 and so on.


Stock calculation issue.xlsx
ABCDEFG
1
2Import orders
3Product nameSKUStockSoldTotal StockBuying priceTotal buying price
4Product 116068500520-2020 Sold out
5Product 216069150015017€ 2.550,00
6Product 116068800080015€ 12.000,00
7Product 116068150015021€ 3.150,00
8Product 316070225022516€ 3.600,00
9
10
11Sold ordersSKUSold
12Product 116068520
13Product 2160690
14Product 3160700
15
16
17Product list
18Product nameSKUStockTotal buying priceAverage price
19Product 116068410€ 15.150,00€ 36,95
20Product 216069150€ 2.550,00€ 17,00
21Product 316070225€ 3.600,00€ 16,00
22
Product list
Cell Formulas
RangeFormula
D4:D8D4=C12
E4:E8E4=[@Stock]-[@Sold]
G4:G8G4=IF([@[Total Stock]]>0,[@[Total Stock]]*[@[Buying price]],"Sold out")
C19C19=(SUMIF(Table1[SKU],$B$19,Table1[Total Stock]))-D4
D19:D21D19=SUMIF(Table1[SKU],B19,Table1[Total buying price])
E19:E21E19=D19/C19
C20C20=(SUMIF(Table1[SKU],$B$20,Table1[Total Stock]))-D5
C21C21=(SUMIF(Table1[SKU],$B$21,Table1[Total Stock]))-D6
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top