Days supply in excel - formula

sasils

New Member
Joined
Jun 3, 2017
Messages
24
Hi,

Need advise from the experts in this forum. Data is below

[TABLE="width: 774"]
<colgroup><col><col span="10"></colgroup><tbody>[TR]
[TD] [/TD]
[TD]W1[/TD]
[TD]W2[/TD]
[TD]W3[/TD]
[TD]W4[/TD]
[TD]W5[/TD]
[TD]W6[/TD]
[TD]W7[/TD]
[TD]W8[/TD]
[TD]W9[/TD]
[TD]W10[/TD]
[/TR]
[TR]
[TD]Forecast[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD]Closing stock[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD]Week supply[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]1.5[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1.5[/TD]
[TD="align: right"]0.5[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]

I would like to get a automatic calculation formulation for Week supply. For example. In Week 1 Week supply is 2 because of Week 1 closing stock can cover forecast for week 2 and week 3 (20+20) - 40 = 0, therefore it is 2.

However in Week 5 Week supply is 1.5 week because week 6 forecast is 10 and week 7 forecast is 20, closing stock in week 5 is 20, therefore week supply base on closing stock week 5 going forward is 1.5.

Hope this explains.

Cheers

Sasils
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Data is in A1:K3

Formula in B4 then drag across
=GetWeeks(B3,C$2:$K$2)

Code for UDF GetWeeks

Code:
Function GetWeeks(ClosingStock As Long, WeekRng As Range)


Dim T As Long


For T = 1 To WeekRng.Cells.Count


    If ClosingStock > WeekRng.Cells(1, T) Then
    GetWeeks = T
    ClosingStock = ClosingStock - WeekRng.Cells(1, T)
    
    ElseIf ClosingStock = WeekRng.Cells(1, T) Then
    GetWeeks = T
    Exit For
    
    Else
    GetWeeks = GetWeeks + Round(ClosingStock / WeekRng.Cells(1, T), 2)
    Exit For
    End If


Next T


End Function

Open tab Developer --> Visual Basic
IN VIsual Basic window

Insert --> Module

Now Paste the given code to module

Close the VB window

UDF is available in the function list like other functions.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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