Today I use this function to calculate months of coverage
=coverage(Cell that holds inventory, range of cells that have the monthly forecast)
=coverage(F7,G5:I5)
I want to use a function that does the same thing, but with value in the function such as :
=coverage(1000,500,250,150,50)
Thoughts ?
Function coverage(inventory, forecast)
Application.Volatile
For Each c In forecast
inventory = inventory - c.Value
Select Case inventory
Case Is > 0
coverage = coverage + 1
Case Is = 0
coverage = coverage + 1
Exit Function
Case Is < 0
If c.Value <> 0 Then
coverage = coverage + (1 - (Abs(inventory) / c.Value))
Else
coverage = coverage
End If
Exit Function
End Select
Next c
End Function
=coverage(Cell that holds inventory, range of cells that have the monthly forecast)
=coverage(F7,G5:I5)
I want to use a function that does the same thing, but with value in the function such as :
=coverage(1000,500,250,150,50)
Thoughts ?
Function coverage(inventory, forecast)
Application.Volatile
For Each c In forecast
inventory = inventory - c.Value
Select Case inventory
Case Is > 0
coverage = coverage + 1
Case Is = 0
coverage = coverage + 1
Exit Function
Case Is < 0
If c.Value <> 0 Then
coverage = coverage + (1 - (Abs(inventory) / c.Value))
Else
coverage = coverage
End If
Exit Function
End Select
Next c
End Function