Results 1 to 2 of 2

Cost of Good Sold VBA Code to formula

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    454

    Cost of Good Sold VBA Code to formula

    Hello,

    I have the below code to calculate the Cost of Goods Sold. Can anyone help me to frame the logic using Array formulas ? ( For Learning purpose)

    Option Explicit
    
    Function FIFO(ByRef Data, ByVal Stock As Double) As Double
        Dim ar As Variant
        Dim i As Long
        Const QtyCol  As Long = 1
        Const CostCol As Long = 2
        
        ar = Data
        
        For i = LBound(ar, 1) To UBound(ar, 1)
            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
        Next i
         
    End Function
    Source : Thesmallman

    Thank you
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formular for cost of individual sold item using fifo
    By xfile in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-02-2023, 02:43 AM
  2. How to calculate cost of item sold at a mark-up of 2.5%?
    By yjohari in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-21-2013, 07:38 PM
  3. Cost of good sold (formula to work out how much to sell item for?)
    By hemeravisuals in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-21-2013, 09:51 PM
  4. Replies: 10
    Last Post: 11-16-2012, 07:54 PM
  5. Costs Price Profit and Cost of goods sold
    By kraysellz in forum Excel General
    Replies: 1
    Last Post: 10-24-2010, 12:56 PM
  6. cost of goods sold formula
    By kim.wilson in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-04-2010, 04:48 PM
  7. Cost of Sold Calc
    By Nath in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2008, 06:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1