FIFO

  • Thread starter Thread starter Michael Wilson
  • Start date Start date
M

Michael Wilson

trying to get this function to work:

Function FIFO(ProductCode As Range, UnitsSold As Range) As Currency
Dim StartCount As Range, UnitCost As Range, Products As Range,
PurchaseUnits As Range
Dim Counter As Integer, RemainingUnits As Long, UnitsAccountedFor As
Long
FIFO = 0
Set Products = Range("ProductCode")
Set StartCount = Range("StartCount")
Set UnitCost = Range("UnitCost")
Set PurchaseUnits = Range("PurchaseUnits")
UnitsAccountedFor = UnitsSold
For Counter = 1 To StartCount.Rows.Count
If ProductCode = Products(Counter, 1) Then
RemainingUnits = Application.WorksheetFunction.Max(0,
StartCount(Counter, 1) + _
PurchaseUnits(Counter, 1) - UnitsAccountedFor)
FIFO = FIFO + UnitCost(Counter, 1) * RemainingUnits
UnitsAccountedFor = UnitsAccountedFor - (StartCount(Counter, 1) +
_
PurchaseUnits(Counter, 1) - RemainingUnits)
End If
Next Counter
End Function

** Posted via: http://www.ozgrid.com
Excel Templates, Training, Add-ins & Software! Free Support at
http://www.ozgrid.com/forum/ **
 
Michael

it might help if you explained what the function was meant to do. And what
cells the various named ranges refer to and what they contain. What does
the function not do that it should ? Or what does it do that it shouldn't ?

How about an example of how you call the function, what data you pass to it
and what result you expect.

Otherwise it is difficult to test ... which may explain the lack of replies

Regards

Trevor
 
Back
Top