# Compound interest calculations using user forms

Home
Excel 2003
Macros Excel 2007
Macros Excel 2003
Excel 2010
Free Ebook
Offline Training
Blog

A user form with labels, text boxes and command buttons is created to display the compound interest calculations. The data is then transferred to an Excel worksheet for further analysis. The code for the 3 command buttons is given below:
Code for the clear command button
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.SetFocus
Code for the Exit command button
If MsgBox("Are you sure you want to exit the program?", vbYesNo) = vbYes Then End
Code for the compound interest calculation button
Dim amount, rate, period, interest As Single
eRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
amount = Val(TextBox1.Text)
Cells(eRow, 1) = amount
rate = (Val(TextBox2.Text)) / 100
Cells(eRow, 2) = rate
period = Val(TextBox3.Text)
Cells(eRow, 3) = period
interest = ((amount) * (1 + rate) ^ period) - amount
Cells(eRow, 4) = interest
TextBox4.Text = Round(interest, 2)

The code is really not difficult to understand. With some practice you should be able to create forms for other financial functions like FV, NPV, etc. In fact, you can try and build a multi-form program!

Excel 2007 Excel 2003 Macros Excel 2007 Macros Excel 2003 Excel 2010