'FINANCE///////////////////////////////////////////////////////////////
Public Account_Balance As Double
Public Case_Selection As String
Public Cash As Double
Public Compound_Amount As Double
Public Future_Worth As Double
Public Interest As Double
Public Interest2 As Double
Public Loan_Payment As Double
Public Period As Integer
Public Present_Worth As Double
Public Total As Double
Public Total_Interest As Double
Sub Calc_Annuity()
'Calculate an
annuity****************************
On Error GoTo No_Annuity
Call Clear_Variables
Cash = InputBox(Prompt:="Enter
the amount you want per year", _
Title:="Payment to You", Default:="0")
Interest = InputBox(Prompt:="Enter
Interest Rate in %", _
Title:="Interest", Default:="0")
Period = InputBox(Prompt:="Enter
number of years of payouts", _
Title:="Length", Default:="0")
Call Calc_Compound_Amount
If Interest > 0
Then
Account_Balance = Cash * (Compound_Amount
- 1) / (Interest2 * Compound_Amount)
Else:
Account_Balance = Cash * Period
End If
Total = Account_Balance
Case_Selection = "Annuity"
Call Print_Results
No_Annuity:
End Sub
Sub Calculate_Future_Worth()
'Calculate future
worth of a sum of money************
On Error GoTo No_Future_Worth
Call Clear_Variables
Cash = InputBox(Prompt:="Enter
the amount you have today", _
Title:="Future Worth of Money Today",
Default:="0")
Interest = InputBox(Prompt:="Enter
Interest Rate in %", _
Title:="Interest", Default:="0")
Period = InputBox(Prompt:="Enter
number of years into the future", _
Title:="Length", Default:="0")
Call Calc_Compound_Amount
Future_Worth = Cash * Compound_Amount
Total = Future_Worth
Case_Selection = "Future Worth"
Call Print_Results
No_Future_Worth:
End Sub
Sub Calculate_Present_Worth()
On Error GoTo No_Present_Worth
Call Clear_Variables
Cash = InputBox(Prompt:="Enter
the amount you will have in the future", _
Title:="Present Worth of Future Money",
Default:="0")
Interest = InputBox(Prompt:="Enter
the Interest Rate in %", _
Title:="Interest", Default:="0")
Period = InputBox(Prompt:="Enter
number of years into the future", _
Title:="Length", Default:="0")
Call Calc_Compound_Amount
Compound_Amount = 1 / Compound_Amount
Present_Worth = Cash * Compound_Amount
Total = Present_Worth
Case_Selection = "Present Worth"
Call Print_Results
No_Present_Worth:
End Sub
Sub Calculate_Loan_Payment()
'Calculate a loan
payment***************************
On Error GoTo No_Loan
Call Clear_Variables
Cash = InputBox(Prompt:="Enter
the amount you are borrowing", _
Title:="Loan amount", Default:="0")
Interest = InputBox(Prompt:="Enter
the Annual Interest Rate in %", _
Title:="Interest", Default:="0")
Period = InputBox(Prompt:="Enter
number of payments in months", _
Title:="Length", Default:="0")
Case_Selection = "Loan Payment"
Call Calc_Compound_Amount
Total_Interest = Cash * (Period * Interest2)
Total = Cash + Total_Interest
Loan_Payment = Total / Period
Total = Loan_Payment
Call Print_Results
ActiveCell.Offset(0, 1).Select
ActiveCell = "Total interest paid = $" & Total_Interest
No_Loan:
End Sub
Sub Calc_Compound_Amount()
'FINANCE*********************************************
On Error GoTo No_Compound
Interest2 =
Interest / 100
If Case_Selection = "Loan Payment" Then
Interest2 =
Interest2 / 12
End If
Compound_Amount = 1
For i = 1 To Period
Compound_Amount = Compound_Amount
* (1 + Interest2)
Next i
No_Compound:
End Sub
Sub Print_Results()
'FINANCE*********************************************
'Find next avaialble line
On Error GoTo Exit_Print
Dim Length As String
Total = Round(Total, 2)
'Sheets("MOD
4 EX").Select
Select Case Case_Selection
Case Is =
"Annuity"
Length = " Years"
Case Is =
"Future Worth"
Length = " Years"
Case Is =
"Present Worth"
Length = " Years"
Case Is =
"Loan Payment"
Length = " Months"
End Select
Range("A1").Select
Do
If ActiveCell = "" Then
ActiveCell = Case_Selection
ActiveCell.Offset(0, 1).Select
ActiveCell = "$" & Cash
ActiveCell.Offset(0, 1).Select
ActiveCell = "@ " &
Interest & " %"
ActiveCell.Offset(0, 1).Select
ActiveCell =
"For " & Period & Length
ActiveCell.Offset(0, 1).Select
ActiveCell = "$" & Total
Exit Do
Else:
ActiveCell.Offset(1, 0).Select
End If
Loop
Exit_Print:
End Sub
Sub Clear_Variables()
Length =
""
Case_Selection = ""
Interest = 0
Interest2 = 0
Period = 0
Total = 0
Future_Worth = 0
Present_Worth = 0
Compound_Amount = 0
Cash = 0
Account_Balance = 0
Total_Interest = 0
Loan_Payment = 0
End Sub
Sub test()
Version = Application.Version
MsgBox (Version)
End Sub