FIFO Valuation not Working Properly

austinandreikurt

Board Regular
Joined
Aug 25, 2020
Messages
91
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I found a FIFO valuation vba that I think is working successfully for some but when I used my figures, it is not. Can you fix this for me?
Original template is from this link: FIFO Calculator — Excel Dashboards VBA

Here is the "ExC" tab from my file:
FIFO_Sample.xlsm
ABCDE
1DateProductQtyCostCost of Goods
201-Jan-21S-TXTL-GRY50$ 84.00$ 4,200.00
331-Jan-21S-TXTL-GRY20$ 86.00$ 1,720.00
425-Feb-21S-TXTL-GRY60$ 90.00$ 5,400.00
525-Mar-21S-TXTL-GRY300$ 105.00$ 31,500.00
626-Mar-21S-TXTL-GRY100$ 101.00$ 10,100.00
715-Apr-21S-TXTL-GRY320$ 200.00$ 64,000.00
815-Apr-21S-TXTL-GRY30$ 20.00$ 600.00
921-May-21S-TXTL-GRY375$ 80.00$ 30,000.00
1009-Dec-21S-TXTL-GRY32$ 100.00$ 3,200.00
ExC
Cell Formulas
RangeFormula
E2:E10E2=D2*C2


And this is the result I get from my SALES reflected in Column D to F:
FIFO_Sample.xlsm
ABCDEF
1RESULT
2
3MonthProduct NameSellCost of Goods SoldRemaining InvFIFO Value
4JanS-TXTL-GRY53$ 4,458.0017$ 1,462.00
5FebS-TXTL-GRY56$ 5,040.004$ 360.00
6MarS-TXTL-GRY59$ 6,195.00341$ 35,405.00
7AprS-TXTL-GRY58$ 11,600.00292$ 53,000.00
8
Results
Cell Formulas
RangeFormula
D4:D7D4=fifo2(ExC!$A$2:$D$10,A4,B4,C4)
E4:E7E4=SUMPRODUCT((MONTH(ExC!$A$2:$A$10)=MONTH(A4))*(ExC!$B$2:$B$10=$B4)*(ExC!$C$2:$C$10))-C4
F4:F7F4=SUMPRODUCT((MONTH(ExC!$A$2:$A$10)=MONTH(A4))*(ExC!$B$2:$B$10=$B4)*(ExC!$E$2:$E$10))-D4


But this should be the actual or desired results based on FIFO method:
FIFO_Sample.xlsm
IJKLMN
1DESIRED RESULT
2
3MonthProduct NameSellCost of Goods SoldRemaining InvFIFO Value
4JanS-TXTL-GRY53$ 4,458.0017$ 1,462.00
5FebS-TXTL-GRY56$ 4,972.0021$ 428.00
6MarS-TXTL-GRY59$ 5,880.00362$ 37,610.00
7AprS-TXTL-GRY58$ 6,090.00654$ 96,120.00
8
9PurchsesSalesRunning Inv
10Jan5050
11Jan2070
12Jan5317
13Feb6077
14Feb5621
15Mar300321
16Mar100421
17Mar59362
18Apr320682
19Apr30712
20Apr58654
21
22
Results
Cell Formulas
RangeFormula
L4L4=(50*84)+(3*86)
M4M4=M12
N4N4=(17*86)
L5L5=(17*86)+(39*90)
M5M5=M14
N5N5=SUMPRODUCT((MONTH(ExC!$A$2:$A$10)=MONTH(I5))*(ExC!$B$2:$B$10=$B5)*(ExC!$E$2:$E$10))-L5
L6L6=(21*90)+(38*105)
M6M6=M17
N6N6=(262*105)+(100*101)
L7L7=58*105
M7M7=M20
N7N7=(204*105)+(100*101)+(320*200)+(30*20)
M11:M20M11=M10+K11-L11



And this is the Function vba for the FIFO formula
VBA Code:
Option Explicit
Function FIFO2(ByRef Data, ByVal Dte As Long, ByVal Product As String, ByVal Stock As Double) As Double
    Dim ar As Variant
    Dim i As Long
    Const DateCol As Long = 1
    Const ProdCol As Long = 2
    Const QtyCol  As Long = 3
    Const CostCol As Long = 4
    
    ar = Data
    
    For i = LBound(ar, 1) To UBound(ar, 1)
        If Month(ar(i, DateCol)) = Month(Dte) Then
            If ar(i, ProdCol) = Product Then
                If Stock < ar(i, QtyCol) Then
                    FIFO2 = FIFO2 + Stock * ar(i, CostCol)
                    Exit Function
                Else
                    FIFO2 = FIFO2 + (ar(i, QtyCol) * ar(i, CostCol))
                    Stock = Stock - ar(i, QtyCol)
                    If Stock <= 0 Then Exit Function
                End If
            End If
        End If
    Next
     
End Function

Thank you in advance!
 
@BSALV ALMOST THERE! ? Just a fix on EOMONTH scope I think? I tried in a different SKU and the Stock which should have been 275 was only 170 and found that it was due to Mar31,2021 remaining inventories not captured and only until Mar30,2021. I have reupdated the link above. Thank you!
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
the link in #5 contains the last version with the Emonth as described in my reaction #10.
So, i think in #11, you were still working with an older version ?
Can you post your actual problem ?
 
Upvote 0
@BSALV I just used the file in link #5 and download and used my data. When I tried to add another SKUs, I got a problem with the running invemtory or in STOCK in COlumn F because it didn't captured March 31 as part of the remaining inventories but it actually adds up that inventory when computing the COGS in Column E.
 
Upvote 0
Hi @BSALV I now know where the problem is. It is because my raw date has time data (3/31/2021 4:30 or 3/31/2021 19:24) and the "<="&EOMONTH only considers 3/31/2021 0:00 as part of the totals. I just need to clean the dates using DATE formula and it now works perfectly. Thank you for your attention on this. Now I have a FIFO tool for inventory that works. Awesome!
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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