Automate Loan Amortization Schedule

How to automate the loan amortization schedule using VBA. Automating monthly payments is useful in many financial situations for people and companies. We first describe the manual process and then show the step by step connection with the macro code. The VBA code to automate the loan amortization schedule is now easy to understand and implement. Watch the video:

Let’s view this video on YouTube.

Here’s the complete VBA code to automate equal period payments based on a fixed rate of interest:

Sub Loan_Amortization()

‘Worksheets(“loanAmortization”).Activate

Rows(7 & “:” & 200).Clear

Dim lastRow As Long, rowNum As Long
lastRow = Sheets(“loanAmortization”).Cells.Find(What:=”*”, _
After:=Range(“A1”), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
‘MsgBox lastRow

nextblankrow = lastRow + 1

Cells(nextblankrow, 1) = “Month”
Cells(nextblankrow, 2) = “Balance Beginning of Loan Period”
Cells(nextblankrow, 3) = “Monthly payment”
Cells(nextblankrow, 4) = “Interest Component of Monthly Payment”
Cells(nextblankrow, 5) = “Principal Component of Monthly Payment”
Cells(nextblankrow, 6) = “Month End Balance”

Columns.AutoFit

Dim intRate, initialLoanAmount, loanPeriod
Dim monthBeginBalance, monthEndBalance
Dim monthlyPayment, interestComponent, principalRepaid

intRate = Range(“B2”)
loanPeriod = Range(“B3”)
initialLoanAmount = Range(“B4”)
‘ Make sure interest rate is not greater than 12%
If intRate > 0.12 Then
MsgBox “Interest rate cannot be greater than 12%.”
Exit Sub
End If

monthlyPayment = Pmt(intRate / 12, loanPeriod, -initialLoanAmount, 0, 0)
monthBeginBalance = initialLoanAmount

For rowNum = 1 To loanPeriod
interestComponent = monthBeginBalance * (intRate / 12)
principalRepaid = monthlyPayment – interestComponent
monthEndBalance = monthBeginBalance – principalRepaid
Cells(nextblankrow + rowNum, 1) = rowNum ‘month number
Cells(nextblankrow + rowNum, 2) = monthBeginBalance
Cells(nextblankrow + rowNum, 3) = monthlyPayment
Cells(nextblankrow + rowNum, 4) = interestComponent
Cells(nextblankrow + rowNum, 5) = principalRepaid
Cells(nextblankrow + rowNum, 6) = monthEndBalance
monthBeginBalance = monthEndBalance
Next rowNum

Range(Cells(8, 2), Cells(nextblankrow + loanPeriod, 6)).NumberFormat = “$#,##0”

End Sub

Sample for download and practice:

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.