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:


Watch this video on YouTube.

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)

End Sub

Further Reading:

Compound Interest

How do I calculate compound interest using Excel?

Compound Interest Calculation

Published by

Dinesh Kumar Takyar

Welcome to! 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: For a structured Excel VBA training course online you can visit:

One thought on “Compound Interest Calculation Using Custom Function”

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.