Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim payment As Double
  2. Dim deposit As Double
  3. Dim intPayment As Double
  4. Dim prodPayment As Double
  5. Dim intDeposit As Double
  6. Dim prodDeposit As Double
  7. Dim endOfIntRegister As Integer
  8. Dim endOfProdRegister As Integer
  9. Dim endOfBankStatement As Integer
  10. Dim registerStart As Integer
  11.  
  12. Dim bankStart As Integer
  13. Dim timesPaymentFound As Integer
  14. Dim timesDepositFound As Integer
  15.  
  16.  
  17. 'times found
  18. timesPaymentFound = 0
  19. timesDepositFound = 0
  20.  
  21. 'First rows
  22. registerStart = 3
  23. bankStart = 3
  24.  
  25. 'Last rows
  26. endOfIntRegister = Cells(2, 31).Value
  27. endOfProdRegister = Cells(2, 32).Value
  28. endOfBankStatement = Cells(2, 33).Value
  29.  
  30.  
  31. '/////////////////////////////////////////////////////////////////////////
  32.  
  33. 'Check Payments of both registers
  34. For i = bankStart To endOfBankStatement
  35.     payment = Cells(i, 28).Value
  36.     If payment > 0 Then
  37.     For j = registerStart To endOfProdRegister
  38.         intPayment = Cells(j, 9).Value
  39.         prodPayment = Cells(j, 21).Value
  40.         'Check both registers
  41.        If payment = intPayment And IsEmpty(Cells(j, 11)) Then
  42.             Cells(j, 11).Value = Cells(i, 26).Value
  43.             Cells(j, 12).Value = payment
  44.             'grey out found row
  45.            For m = 1 To 9
  46.                 Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
  47.                Cells(j, m).Font.Color = RGB(100, 100, 100)
  48.             Next m
  49.             timesPaymentFound = timesPaymentFound + 1
  50.             Exit For
  51.         ElseIf payment = prodPayment And IsEmpty(Cells(j, 23)) Then
  52.             Cells(j, 23).Value = Cells(i, 26).Value
  53.             Cells(j, 24).Value = payment
  54.             'grey out found row
  55.            For m = 13 To 21
  56.                 Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
  57.                Cells(j, m).Font.Color = RGB(100, 100, 100)
  58.             Next m
  59.             timesPaymentFound = timesPaymentFound + 1
  60.         End If
  61.     Next j
  62.     End If
  63.     'if not found in either register highlight payment
  64.   If payment > 0 And timesPaymentFound <= 0 Then
  65.         For k = 25 To 28
  66.             Cells(i, k).Interior.Color = RGB(255, 255, 153)
  67.         Next k
  68.     End If
  69.     'if found, grey it out
  70.   If payment > 0 And timesPaymentFound > 0 Then
  71.         For k = 25 To 28
  72.         Cells(i, k).Interior.Color = RGB(230, 230, 230)
  73.         Next k
  74.     End If
  75.     timesPaymentFound = 0
  76. Next i
  77.  
  78.  
  79.  
  80. '/////////////////////////////////////////////////////////////////////////
  81.  
  82.  
  83. 'Check Deposits of both registers
  84. For i = bankStart To endOfBankStatement
  85.     deposit = Cells(i, 27).Value
  86.     If deposit > 0 Then
  87.     For j = registerStart To endOfProdRegister
  88.         intDeposit = Cells(j, 7).Value
  89.         prodDeposit = Cells(j, 19).Value
  90.         'Check both registers
  91.        If deposit = intDeposit And IsEmpty(Cells(j, 11)) Then
  92.             Cells(j, 11).Value = Cells(i, 26).Value
  93.             Cells(j, 10).Value = deposit
  94.             'grey out found row
  95.            For m = 1 To 9
  96.                 Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
  97.                Cells(j, m).Font.Color = RGB(100, 100, 100)
  98.             Next m
  99.             timesDepositFound = timesDepositFound + 1
  100.             Exit For
  101.         ElseIf deposit = prodDeposit And IsEmpty(Cells(j, 23)) Then
  102.             Cells(j, 23).Value = Cells(i, 26).Value
  103.             Cells(j, 24).Value = deposit
  104.             'grey out found row
  105.            For m = 13 To 21
  106.                 Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
  107.                Cells(j, m).Font.Color = RGB(100, 100, 100)
  108.             Next m
  109.             timesDepositFound = timesDepositFound + 1
  110.         End If
  111.     Next j
  112.     End If
  113.     'if not found in either register highlight payment
  114.   If deposit > 0 And timesDepositFound <= 0 Then
  115.         For k = 25 To 28
  116.             Cells(i, k).Interior.Color = RGB(255, 255, 153)
  117.         Next k
  118.     End If
  119.     'if found, grey it out
  120.   If deposit > 0 And timesDepositFound > 0 Then
  121.         For k = 25 To 28
  122.         Cells(i, k).Interior.Color = RGB(230, 230, 230)
  123.         Next k
  124.     End If
  125.     timesDepositFound = 0
  126. Next i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement