VBA Code:
Sub Case_Automation()
Dim a As Long
Dim b As String
Dim c As Long
Dim d As Long
Dim e As Long
Dim f As Long
Dim g As Long
Dim h As Long
Dim z As Long
Dim j As Long
Dim k As Long
For z = 10 To 50003
a = Cells(z, 8).Value
b = Cells(z, 27).Value
c = Cells(z, 14).Value
d = Cells(z, 18).Value
e = Cells(z, 28).Value
f = Cells(z, 30).Value
g = Cells(z, 36).Value
h = Cells(z, 38).Value
j = Cells(z, 31).Value
k = Cells(z, 33).Value
Cells(z, 1) = Case_Number(a, b, c, d, e, f, g, h, j, k)
Next
End Sub
Function Case_Number(PO_Date As Long, PO_Status As String, PO_Quantity As Long, PO_Value As Long, Still_to_be_delivered_Quantity As Long, Still_to_be_delivered_value As Long, Delivered_Quantity As Long, Delivered_value As Long, Still_to_be_invoiced_quantity As Long, Still_to_be_invoiced_value As Long)
' a b c d e f g h j k
Dim z As String
Dim inter As Integer
'"Still to be Delievered
'Qty = NIL
'Value = NIL
'Still to be Invoiced = NIL"
If PO_Status = "Blocked" Then
If Still_to_be_deliverd_quantity = 0 Then
If Still_to_be_delivered_value = 0 Then
If Still_to_be_invoiced_quantity = 0 Then
z = "Case 1"
Case_Number = z
End If
End If
End If
End If
If PO_Status = "Deleted" Then
If Still_to_be_deliverd_quantity = 0 Then
If Still_to_be_delivered_value = 0 Then
If Still_to_be_invoiced_quantity = 0 Then
z = "Case 2"
Case_Number = z
End If
End If
End If
End If
If PO_Status = "Open" Then
If PO_Date <= 43465 Then
z = "Case 9"
Case_Number = z
End If
If PO_Date > 43465 Then
z = "Case 10"
Case_Number = z
End If
If PO_Quantity = Still_to_be_delivered_Quantity Then
If Still_to_be_delivered_value = PO_Value Then
If Delivered_value = 0 Then
z = "Case 3"
Case_Number = z
Exit Function
End If
End If
End If
If Still_to_be_delivered_Quantity = PO_Quantity Then
If Delivered_Quantity = 0 Then
If Still_to_be_delivered_value = 0 Then
If Delivered_value = PO_Value Then
z = "Case 4"
Case_Number = z
Exit Function
End If
End If
End If
End If
If Still_to_be_delivered_Quantity = 0 Then
If Still_to_be_delivered_value = 0 Then
If Delivered_value = PO_Value Then
z = "Case 5"
Case_Number = z
Exit Function
End If
End If
End If
If Still_to_be_delivered_Quantity = 0 Then
If Delivered_value = PO_Value Then
If Delivered_value = 0 Then
z = "Case 6"
Case_Number = z
Exit Function
End If
End If
End If
If Still_to_be_delivered_Quantity = 0 Then
If Delivered_value = PO_Value Then
If Delivered_value = 0 Then
z = "Case 6"
Case_Number = z
Exit Function
End If
End If
End If
If Still_to_be_delivered_Quantity = 0 Then
If Delivered_value < PO_Value Then
If Delivered_value < PO_Value Then
z = "Case 7"
Case_Number = z
Exit Function
End If
End If
End If
If Still_to_be_delivered_Quantity > 0 Then
If Delivered_Quantity > 0 Then
If Still_to_Delivered_value = 0 Then
If Delivered_value = PO_Value Then
z = "Case 8"
Case_Number = z
Exit Function
End If
End If
End If
End If
End If
End Function
Please help...."i" value stops after 1482...till there loop rund fine
Last edited by a moderator: