Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim payment As Double
- Dim deposit As Double
- Dim intPayment As Double
- Dim prodPayment As Double
- Dim intDeposit As Double
- Dim prodDeposit As Double
- Dim endOfIntRegister As Integer
- Dim endOfProdRegister As Integer
- Dim endOfBankStatement As Integer
- Dim registerStart As Integer
- Dim bankStart As Integer
- Dim timesPaymentFound As Integer
- Dim timesDepositFound As Integer
- 'times found
- timesPaymentFound = 0
- timesDepositFound = 0
- 'First rows
- registerStart = 3
- bankStart = 3
- 'Last rows
- endOfIntRegister = Cells(2, 31).Value
- endOfProdRegister = Cells(2, 32).Value
- endOfBankStatement = Cells(2, 33).Value
- '/////////////////////////////////////////////////////////////////////////
- 'Check Payments of both registers
- For i = bankStart To endOfBankStatement
- payment = Cells(i, 28).Value
- If payment > 0 Then
- For j = registerStart To endOfProdRegister
- intPayment = Cells(j, 9).Value
- prodPayment = Cells(j, 21).Value
- 'Check both registers
- If payment = intPayment And IsEmpty(Cells(j, 11)) Then
- Cells(j, 11).Value = Cells(i, 26).Value
- Cells(j, 12).Value = payment
- 'grey out found row
- For m = 1 To 9
- Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
- Cells(j, m).Font.Color = RGB(100, 100, 100)
- Next m
- timesPaymentFound = timesPaymentFound + 1
- Exit For
- ElseIf payment = prodPayment And IsEmpty(Cells(j, 23)) Then
- Cells(j, 23).Value = Cells(i, 26).Value
- Cells(j, 24).Value = payment
- 'grey out found row
- For m = 13 To 21
- Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
- Cells(j, m).Font.Color = RGB(100, 100, 100)
- Next m
- timesPaymentFound = timesPaymentFound + 1
- End If
- Next j
- End If
- 'if not found in either register highlight payment
- If payment > 0 And timesPaymentFound <= 0 Then
- For k = 25 To 28
- Cells(i, k).Interior.Color = RGB(255, 255, 153)
- Next k
- End If
- 'if found, grey it out
- If payment > 0 And timesPaymentFound > 0 Then
- For k = 25 To 28
- Cells(i, k).Interior.Color = RGB(230, 230, 230)
- Next k
- End If
- timesPaymentFound = 0
- Next i
- '/////////////////////////////////////////////////////////////////////////
- 'Check Deposits of both registers
- For i = bankStart To endOfBankStatement
- deposit = Cells(i, 27).Value
- If deposit > 0 Then
- For j = registerStart To endOfProdRegister
- intDeposit = Cells(j, 7).Value
- prodDeposit = Cells(j, 19).Value
- 'Check both registers
- If deposit = intDeposit And IsEmpty(Cells(j, 11)) Then
- Cells(j, 11).Value = Cells(i, 26).Value
- Cells(j, 10).Value = deposit
- 'grey out found row
- For m = 1 To 9
- Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
- Cells(j, m).Font.Color = RGB(100, 100, 100)
- Next m
- timesDepositFound = timesDepositFound + 1
- Exit For
- ElseIf deposit = prodDeposit And IsEmpty(Cells(j, 23)) Then
- Cells(j, 23).Value = Cells(i, 26).Value
- Cells(j, 24).Value = deposit
- 'grey out found row
- For m = 13 To 21
- Cells(j, m).Interior.Color = RGB(220, 220, 220) 'grey
- Cells(j, m).Font.Color = RGB(100, 100, 100)
- Next m
- timesDepositFound = timesDepositFound + 1
- End If
- Next j
- End If
- 'if not found in either register highlight payment
- If deposit > 0 And timesDepositFound <= 0 Then
- For k = 25 To 28
- Cells(i, k).Interior.Color = RGB(255, 255, 153)
- Next k
- End If
- 'if found, grey it out
- If deposit > 0 And timesDepositFound > 0 Then
- For k = 25 To 28
- Cells(i, k).Interior.Color = RGB(230, 230, 230)
- Next k
- End If
- timesDepositFound = 0
- Next i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement