how to substract sales from stock with oldest date first and then move to next date?

illusionek

Board Regular
Joined
Jun 21, 2014
Messages
104
Hello!

Until now, I thought I know Excel well but below is above my abilities. Can anyone help?

Please see my problem below:


Stock spreadsheet has all the items I am trying to sell with 'sell by date' after which I cannot sell this item. Then in Sales Forecast I have forecasted sales. So now I am trying to calculate stock consumption to see if I will be left with any stock that I cannot sell.

I need to deduct sales forecast from my stock holding but it needs to go by date i.e. consume all stock for Item 1 with date 16/09 before moving to Item 1 with 'sale by date' 23/09 and so on.

So based on the attached example, I can see that on 16/09 I will consume only 5 cases from 'sell by date' 16/09 and another sale is 18/09. So that would give me information that I will be left with 95 items dated 16/09, which I cannot sell because they will be out of date.

Ideally I would like also to include the logic that if Item is out of date it would move to the next 'sell by date' and if possible I would like to avoid VBA.

So in this case sale of Item 1 forecasted for 18/09 (94) would consume the whole stock (50) with date 23/09 and another 44 from date 01/10

For Item 2 I can see that units with 'Sell by date' 30/09 will be consumed on 25/09 and I will start taking stock from next 'sell by date' which is 14/10.

I hope all this makes sense and someone would be able to help me out.

I attached both spreadsheets plus an illustration of a solution I am looking for, which at the moment is done manually.


Thank you in advance for all help.


Stock:
stock.png


Sales:
sales.png



Solution:
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Please find below:

Stock:
ProductQtySell by date
Item 110016/09/2014
Item 15023/09/2014
Item 21130/09/2014
Item 250014/10/2014
Item 110001/10/2014

<tbody>
</tbody><colgroup><col span="2"><col></colgroup>


Sales:
ProductForecasted QtyForecasted Sale Date
Item 1516/09/2014
Item 2118/09/2014
Item 19418/09/2014
Item 1520/09/2014
Item 21525/09/2014
Item 21129/09/2014

<tbody>
</tbody><colgroup><col span="2"><col></colgroup>

Desired Solution:
Item NameSell By DateSell By Date Qty16/09/201417/09/201418/09/201419/09/201420/09/201421/09/201422/09/201423/09/201424/09/201425/09/201426/09/201427/09/201428/09/201429/09/2014
Item 116/09/201410095
Item 123/09/2014505050
Item 101/10/2014100100100565651515151515151515151
Item 230/09/201411111110101010101010
Item 214/10/2014500500500500500500500500500500495495495495484

<tbody>
</tbody><colgroup><col><col><col><col span="14"></colgroup>
 
Upvote 0
ilusionek,

Can you tell me if it is an easy matter for you to have your columns B, C, & D data i.e. Item, Date & Qty, within the Solution sheet, sorted by item / date order as per your sample file?
 
Upvote 0
Hopefully, the following will be of some value.
Because the stock balances are the product of whatever pattern of sales that precedes them, I have not been able to find a direct way to calculate the stock balances.
I have had to settle for an intermediate 'helper' sheet ,'Stock Helper' that calculates the sales to date for each batch of stock and then in the 'Stock' sheet, deduct these values from the total batch quantity in order to get the unsold balance.
I have added an, Available Date as in the date the batch of items is available from stock.

So....

Sales forecast pretty much as was.
Excel Workbook
1ProductForecast SaleDate
2Item 1516/09/2014
3Item 2118/09/2014
4Item 19418/09/2014
5Item 1520/09/2014
6Item 21525/09/2014
7Item 21129/09/2014
8Item 3925/09/2014
9Item 31026/09/2014
10Item 1520/09/2014
Excel 2007
<p style="width:7.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sale Forcast</p>

Stock Helper sheet. Once formulas are extended to suit your data there is no need for data entry in this sheet. In fact it could be hidden.

Excel Workbook
1Row 3 data linked to Stock sheet row 3 by formula. ****NO DATA INPUT IN THIS SHEET***** Just extend formulas down and across as required*****
2Data in B4:E?? Linked to Stock sheet by formula. Cells F4:?? Contain Sales values calcu;ated by formula -- can drag B4:?? Down as required and F3:F?? Across as required
3Item NameAvailable DateSell By DateSell By Date Qty16/09/201417/09/201418/09/201419/09/201420/09/201421/09/201422/09/201423/09/201424/09/201425/09/2014
4Item 115/09/201416/09/20141005555555555
5Item 116/09/201423/09/201450005050505050505050
6Item 117/09/201401/10/2014100004444545454545454
7Item 101/10/201405/10/2014750000000000
8Item 217/09/201430/09/20141100111111111
9Item 223/09/201414/10/20145000000000005
10Item 223/09/201428/09/2014500000000000
11Item 225/09/201402/10/2014400000000000
12Item 319/09/201403/10/2014120000000009
Excel 2007
<p style="width:7.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Stock Helper</p><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B3</th><td style="text-align:left">=IF(<font color="Blue">Stock!B3="","",Stock!B3</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B4</th><td style="text-align:left">=IF(<font color="Blue">Stock!B4="","",Stock!B4</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">F3</th><td style="text-align:left">=Stock!F3</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">F4</th><td style="text-align:left">=MIN(<font color="Blue">SUMIFS(<font color="Red">'Sale Forcast'!$B$2:$B$20,'Sale Forcast'!$A$2:$A$20,$B4,'Sale Forcast'!$C$2:$C$20,"<="&MIN(<font color="Green">F$3,$D4</font>)</font>)-SUMIF(<font color="Red">$B$3:$B3,$B4,F$3:F3</font>),$E4</font>)</td></tr></table></td></tr></table>


Stock sheet. Dates to be entered in green cells row 3 as far as required.
Stock receipt details entered in yellow cells.
F4 formula copy down and across as required ( in line with Stock Helper range)

Yellow rows B4:E?? can be sorted but balances will compute even if not sorted.

White cells compute balance available on given day.
There are values in cells that appear blank but they have white text by virtue of conditional formatting.
Cells where balance remains unsold by Sell By Date will highlight red.



Excel Workbook
BCDEFGHIJKLMNOPQRSTUVW
3Item NameAvailable DateSell By DateSell By Date Qty16/0917/0918/0919/0920/0921/0922/0923/0924/0925/0926/0927/0928/0929/0930/0901/1002/1003/10
4Item 115/09/201416/09/2014100959595959595959595959595959595959595
5Item 116/09/201423/09/20145050500000000000000000
6Item 117/09/201401/10/2014100-10056564646464646464646464646464646
7Item 101/10/201405/10/201475---------------757575
8Item 217/09/201430/09/201411-1110101010101010000000000
9Item 223/09/201414/10/2014500-------500500495495495495484484484484484
10Item 223/09/201428/09/201450-------5050505050506161616161
11Item 225/09/201402/10/201440---------404040402929292929
12Item 319/09/201403/10/201412---121212121212300000000
13------------------
Stock
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F41. / Formula is =AND(F4>0,G4>0,F$3=$D4)Abc
F42. / Formula is =OR(F$3>$D4,F4=0)Abc


I think that's about it?

Link to file available here as at time of posting. File

Hope that helps.


 
Upvote 0

Forum statistics

Threads
1,215,443
Messages
6,124,889
Members
449,193
Latest member
ronnyf85

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