In this article, we are going to learn how to create calculator to calculate the Interest amount through VBA in Microsoft Excel.
User Form: – User form is used to enter the specific details in the data, which is basically used by the users who are not friendly with the Excel. Through user form, we can restrict the entries and assign the cells in which that particular entry is required.
We want to create a user form to enter the few details and then Excel will calculate the Interest amount.
Follow below given steps to create the User form for Interest amount calculation
Private Sub CommandButton1_Click() Dim Amount, rate, duration, interest As Single Dim erow As Integer erow = Worksheets("Sheet1").Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row Amount = Val(TextBox1.text) Cells(erow, 1).Value = Amount rate = Val(TextBox2.text) / 100 Cells(erow, 2).Value = rate Cells(erow, 2).Value = Cells(erow, 2) * 100 & "%" duration = Val(TextBox3.text) Cells(erow, 3).Value = duration interest = ((Amount * (1 + rate) ^ duration) - Amount) Cells(erow, 4).Value = interest End Sub
Code Explanation: – First, we will define the variables, and then we will define rows and cells where we want to capture the details in the text box.
Now, we will insert a button to open the user form, follow below given steps:-
Sub Button5_Click() Interest_Cal.Show End Sub
In this way, we can create the loan calculator in Microsoft Excel by using VBA coding in Microsoft Excel.
We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at email@example.com
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.