title: Loan amortization schedule
body: <p>I need to generate a loan table for an interest rate 8%, loan life 15 years, and initial loan amount £200,000. I've used the below VBA code on excel 2010, but it is not displaying the table correctly, this is the code that I've used;</p>
  
  <pre><code>Sub LoanSchedule()
  
  Dim intRate, loanLife, initLoan, payment
  
  intRate = InputBox("Input Interest rate:")
  loanLife = InputBox("Input Loan life:")
  initLoan = InputBox("Input Loan amount:")
  
  Cells(4, 2).Value = intRate
  Cells(5, 2).Value = loanLife
  Cells(6, 2).Value = initLoan
  
  payment = Pmt(intRate, loanLife, -initLoan)
  
  'Year-beg Bal    Annual Payment  Interest Component  Prinicipal Repaid   Year-end Bal
   Dim yearBegBal, intComp, prinComp, yearEndBal
  
  outRow = 10
  yearBegBal = LoanAmtBal
  
  For rowNum = 1 To loanLife
  intComp = yearBegBal * intRate
  prinComp = payment - intComp
  yearEndBal = yearBegBal - prinComp
  
  Cells(outRow + rowNum, 1).Value = rowNum
  Cells(outRow + rowNum, 2).Value = yearBegBal
  Cells(outRow + rowNum, 3).Value = payment
  Cells(outRow + rowNum, 4).Value = intComp
  Cells(outRow + rowNum, 5).Value = prinComp
  Cells(outRow + rowNum, 6).Value = yearEndBal
  
  yearBegBal = yearEndBal
  Next rowNum
  
  End Sub
  </code></pre>
  
  <p>as I am a beginner to VBA, would someone be able to help me please.</p>