Results 1 to 14 of 14

FIFO Based Receipt Adjustment To determine date when particular invoice is finally cleared

Threaded View

spremkishan FIFO Based Receipt Adjustment... 08-12-2015, 02:24 AM
excelliot Re: FIFO Based Receipt... 08-12-2015, 02:42 AM
excelliot Re: FIFO Based Receipt... 08-12-2015, 11:20 AM
spremkishan Re: FIFO Based Receipt... 08-12-2015, 12:25 PM
excelliot Great.. mark this as solved. 08-12-2015, 01:36 PM
excelliot Re: FIFO Based Receipt... 08-15-2015, 05:09 AM
spremkishan Re: FIFO Based Receipt... 08-15-2015, 10:55 AM
excelliot upload sample file, with new... 08-15-2015, 11:46 AM
spremkishan Re: FIFO Based Receipt... 08-15-2015, 03:04 PM
excelliot Re: FIFO Based Receipt... 08-16-2015, 03:19 AM
spremkishan Re: FIFO Based Receipt... 08-16-2015, 04:23 AM
excelliot Re: FIFO Based Receipt... 08-17-2015, 05:06 AM
sparaguak Re: FIFO_Logic.xlsm 11-20-2019, 06:49 AM
JeteMc Re: FIFO Based Receipt... 11-22-2019, 08:27 PM
  1. #3
    Forum Contributor
    Join Date
    06-24-2005
    Location
    excelliot.com
    MS-Off Ver
    2007
    Posts
    325

    Re: FIFO Based Receipt Adjustment To determine date when particular invoice is finally cle

    Hi

    check this attachment..maintain data as per two sheet & click on blue button to run code:

    updated code is:

    Sub fifoadjustment()
    Dim i As Integer, j As Integer, customer As String
    Dim payment_bal As Long, invoice_bal As Long, invoice_amt As Long
    Dim assigned As Long
    
    payment_bal = 0
    invoice_bal = 0
    invoice_amt = 0
    
    Sheets("Payments").Range("E2:E50000").Value = ""
    Sheets("Invoice").Range("E2:E50000").Value = ""
    
    For i = 2 To Sheets("Invoice").Range("A55000").End(xlUp).Row
    invoice_amt = Sheets("Invoice").Cells(i, 2).Value
    customer = Sheets("Invoice").Cells(i, 3).Value
    invoice_bal = 0
    payment_bal = 0
    assigned = 0
        For j = 2 To Sheets("Payments").Range("A55000").End(xlUp).Row
        If Sheets("Payments").Cells(j, 3).Value = customer Then
        If Sheets("Payments").Cells(j, 5).Value = "" Then
                If invoice_bal = 0 Then
                   If Sheets("Payments").Cells(j, 2).Value < invoice_amt Then
                      invoice_bal = invoice_amt - Sheets("Payments").Cells(j, 2).Value
                      payment_bal = 0: Sheets("Payments").Cells(j, 5).Value = 0
                      
                   End If
                Else
                      assigned = Application.WorksheetFunction.Min(Sheets("Payments").Cells(j, 2).Value, invoice_bal)
                      invoice_bal = invoice_bal - assigned 'Application.WorksheetFunction.Min(Sheets("Payments").Cells(j, 2).Value, invoice_bal)
                End If
                If invoice_bal = 0 Then
                   Sheets("Invoice").Cells(i, 5).Value = Sheets("Payments").Cells(j, 1).Value
                   If assigned = 0 Then
                   payment_bal = Sheets("Payments").Cells(j, 2).Value - invoice_amt
                   Else
                   payment_bal = Sheets("Payments").Cells(j, 2).Value - assigned
                   End If
                   Sheets("Payments").Cells(j, 5).Value = payment_bal 'Sheets("Payments").Cells(j, 5).Value - assigned
                Else
                   Sheets("Invoice").Cells(i, 5).Value = "Amt recieved " & invoice_amt - invoice_bal
                End If
        
        Else
            If Sheets("Payments").Cells(j, 5).Value <> 0 Then
                If invoice_bal = 0 Then
                   If Sheets("Payments").Cells(j, 5).Value < invoice_amt Then
                      invoice_bal = invoice_amt - Sheets("Payments").Cells(j, 5).Value
                      payment_bal = 0: Sheets("Payments").Cells(j, 5).Value = 0
                   End If
                Else
                      assigned = Application.WorksheetFunction.Min(Sheets("Payments").Cells(j, 5).Value, invoice_bal)
                      invoice_bal = invoice_bal - Application.WorksheetFunction.Min(Sheets("Payments").Cells(j, 2).Value, invoice_bal)
                End If
                If invoice_bal = 0 Then
                   Sheets("Invoice").Cells(i, 5).Value = Sheets("Payments").Cells(j, 1).Value
                   If assigned = 0 Then
                   payment_bal = Sheets("Payments").Cells(j, 2).Value - invoice_amt
                   Else
                   payment_bal = Sheets("Payments").Cells(j, 2).Value - assigned
                   End If
                   Sheets("Payments").Cells(j, 5).Value = payment_bal 'Sheets("Payments").Cells(j, 5).Value - assigned
                Else
                   Sheets("Invoice").Cells(i, 5).Value = "Amt recieved " & invoice_amt - invoice_bal
                End If
            End If
        End If
        End If
        Next j
    Next i
    End Sub
    Cheers!!
    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] Invoice Description items based on start and end date
    By Learning ExL in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2015, 11:38 AM
  2. [SOLVED] Automatic invoice charges based on date selection
    By Kym-B in forum Excel General
    Replies: 13
    Last Post: 11-21-2013, 01:07 PM
  3. Formula to determine due date based on hire date
    By tastjuste in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-17-2013, 06:59 PM
  4. [SOLVED] Make vlookup reset back to Name or blank after invoice is saved and cleared
    By jfolson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2013, 08:25 AM
  5. [SOLVED] Determine date based on request date meanwhile falls on particular days
    By Hikari in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-18-2013, 09:37 AM
  6. Replies: 4
    Last Post: 11-04-2012, 12:43 PM
  7. Date of Receipt based on In/OUT
    By cmcconna in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2010, 06:47 PM

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