Purpose :
I need to assign the current status to invoices based on Status , Due date , Payment Number and Balance amount
If Status is POSTED , Payment number is available , and no balance amount status should be "Invoice Fully Paid"
ele next if condition
Sub Status() ' ' Status Macro '
' Dim ColNumST As Integer Dim ColNumDD As Integer Dim ColNumPN As Integer Dim ColNumPA As Integer Dim ColNumIN As Integer Dim ColNumCS As Integer
Dim SelRange As Range Dim CWS As Worksheet
Sheets("All Invoices").Select
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Pending Invoice"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Pending Amount"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Current Status"
Set CWS = ActiveSheet
ColNumST = Application.WorksheetFunction.Match("Status", CWS.Rows(1), 0)
ColNumDD = Application.WorksheetFunction.Match("Invoice Due Date", CWS.Rows(1), 0)
ColNumPN = Application.WorksheetFunction.Match("Payment Number", CWS.Rows(1), 0)
ColNumPA = Application.WorksheetFunction.Match("Pending Amount", CWS.Rows(1), 0)
ColNumIN = Application.WorksheetFunction.Match("Invoice#", CWS.Rows(1), 0)
ColNumCS = Application.WorksheetFunction.Match("Current Status", CWS.Rows(1), 0)
Set SelRange = CWS.Columns(ColNumST)
Set SelRange = CWS.Columns(ColNumDD)
Set SelRange = CWS.Columns(ColNumPA)
Set SelRange = CWS.Columns(ColNumPN)
Set SelRange = CWS.Columns(ColNumIN)
Set SelRange = CWS.Columns(ColNumCS)
lastrow1 = ThisWorkbook.Worksheets("All Invoices").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow1
If Range("ColNumST" & i).Value = "POSTED" And Range(ColNumPN & i).Value > 1 And Range(ColNumPA & i).Value = 0 Then
Range("ColNumCS").Value = "Invoice Fully Paid"
Else
Aucun commentaire:
Enregistrer un commentaire