آخر الأخبار

جاري التحميل ...

Function FIFO code vba in excel

Function FIFO

The difference between FIFO and LIFO results from the order in which changing unit costs are removed from inventory and become the cost of goods sold. When the unit costs have increased, LIFO will result in a larger cost of goods sold and a smaller ending inventory compared with FIFO

now we will see Function FIFO code vba in excel

Option Explicit

Function FIFO(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
                    FIFO = FIFO + Stock * ar(i, CostCol)
                    Exit Function
                Else
                    FIFO = FIFO + (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

عن الكاتب

Acc-Mohamed ElSayed

التعليقات



إذا أعجبك محتوى مدونتنا نتمنى البقاء على تواصل دائم ، فقط قم بإدخال بريدك الإلكتروني للإشتراك في بريد المدونة السريع ليصلك جديد المدونة أولاً بأول ، كما يمكنك إرسال رساله بالضغط على الزر المجاور ...

إتصل بنا

جميع الحقوق محفوظة لـ

احترف برمجه الاكسيل و الاكسيس

2017