Private Sub CommandButton3_Click()
Dim Opening As Double
Dim Credit
Dim Continue As VbMsgBoxResult
Dim con As VbMsgBoxResult
Dim TranType As String
Dim Closing As Double
Dim Time As Date
Credit = InputBox("Enter Credit Amount", "Credit Function")
If IsNumeric(Credit) = False Then
Continue = msgbox("Incorrect Value Entered", , "Credit Function")
ElseIf IsNumeric(Credit) = True Then
Opening = Range("D80000").End(xlUp).value
Closing = Opening - Credit
If Closing < 0 Then
con = msgbox("overdraft", vbYesNo, "")
End If
If con = vbYes Then
Opening = Range("D80000").End(xlUp).value
Range("A80000").End(xlUp).Offset(1, 0).value = Opening
Range("B80000").End(xlUp).Offset(1, 0).value = Credit
Closing = Opening - Credit
Range("D80000").End(xlUp).Offset(1, 0).value = Closing
TranType = "Out"
Range("C80000").End(xlUp).Offset(1, 0).value = TranType
Time = Date
Range("E80000").End(xlUp).Offset(1, 0).value = Time
transaction.TextBox3 = Credit
transaction.TextBox1 = Closing
transaction.TextBox4 = Format(Date, "dd-mm-yyyy")
Continue = msgbox("Your Transaction Has Been Succeful" & vbCrLf & "" & vbCrLf & "Opening Balance: £" & Opening & vbCrLf & "" & vbCrLf & "Credit Amount: £" & Credit & vbCrLf & "" & vbCrLf & "Closing Balance: £" & Closing, vbOKOnly, "Transaction Succesful")
End If
If con = vbNo Then End
End If
If Closing > 0 Then
Opening = Range("D80000").End(xlUp).value
Range("A80000").End(xlUp).Offset(1, 0).value = Opening
Range("B80000").End(xlUp).Offset(1, 0).value = Credit
Closing = Opening - Credit
Range("D80000").End(xlUp).Offset(1, 0).value = Closing
TranType = "Out"
Range("C80000").End(xlUp).Offset(1, 0).value = TranType
Time = Date
Range("E80000").End(xlUp).Offset(1, 0).value = Time
transaction.TextBox3 = Credit
transaction.TextBox1 = Closing
transaction.TextBox4 = Format(Date, "dd-mm-yyyy")
Continue = msgbox("Your Transaction Has Been Succeful" & vbCrLf & "" & vbCrLf & "Opening Balance: £" & Opening & vbCrLf & "" & vbCrLf & "Credit Amount: £" & Credit & vbCrLf & "" & vbCrLf & "Closing Balance: £" & Closing, vbOKOnly, "Transaction Succesful")
End If
End Sub