January 9, 2018

# Compound Interest Calculation Using Custom Function

How to calculate the compound interest using a custom or user-defined function in Excel with VBA. The concept and calculation of compound interest is of great value in many business situations, especially while making investments. The interest earned on the principal is as added to the principal. This new principal then earns a greater interest. Keeping the time factor in mind the earnings through compounding are much larger than with simple interest. watch the video below to see how we can automate the compound interest calculations in Excel using a custom function:

Here’s the complete VBA code:

Function CompoundInt(LoanAmt As Currency, Rate As Double, Period As Long)

CompoundInt = (LoanAmt * (1 + Rate) ^ Period) – LoanAmt

End Function

Sub calculateCompoundInt()

Dim LoanAmt As Currency
Dim Rate As Double
Dim Period As Long

LoanAmt = Range(“B1”).Value
Rate = Range(“B2”).Value
Rate = Rate / 100
Period = Range(“B3”).Value
Range(“B4”).Value = CompoundInt(LoanAmt, Rate, Period)
Range(“A1:B4”).Columns.AutoFit

End Sub