I'm having trouble getting my amortization table to work properly. I can get all of the fields to work except for the balance column. Can someone offer some advice on how to fix it. Here is my current code:
Option Explicit
Public Sub Amortization()
Dim Var1 As Single, Var2 As Integer, Var3 As Currency, x As Integer, y As Integer, Principle As Currency, _
Balance As Currency, Interest As Currency, Payment As Currency
y = 7
'Input Numbers
Range("a1:a4").Font.Bold = True
Var1 = InputBox("Enter the rate of the loan in decimal form")
Var2 = InputBox("Enter the number of years of loan")
Var3 = InputBox("Enter the amount of the loan")
Range("a1").Value = "Rate of loan"
Range("a2").Value = "Number of years"
Range("a3").Value = "Amount borrowed"
Range("a4").Value = "Payment"
Range("b1").Value = Var1 & "%"
Range("b2").Value = Var2
Range("b3").Value = Var3
Range("b4").Formula = "=-PMT(B1/12,B2*12,B3)"
'Amorization Table
Range("c6:g6").Font.Bold = True
Range("c6").Value = "Period"
Range("d6").Value = "Payment"
Range("e6").Value = "Interest"
Range("f6").Value = "Principle"
Range("g6").Value = "Balance"
For x = 1 To Var2 * 12
Sheet1.Cells(y, 3) = x
Sheet1.Cells(y, 4) = "=$b$4"
Interest = (-IPmt(Var1 / 1200, x, Var2 * 12, Var3))
Sheet1.Cells(y, 5) = (Interest)
Principle = (-PPmt(Var1 / 1200, x, Var2 * 12, Var3))
Sheet1.Cells(y, 6) = (Principle)
Balance = Balance - Principle
Sheet1.Cells(y, 7) = (Balance)
y = y + 1
Next x
Columns("a:g").EntireColumn.AutoFit
End Sub
Thanks
Bookmarks