### VBA Projects

###### Full Access with Source Code
• Designed and Developed by PNRao

• Full Access with VBA Source Code

• Well Commented Codes Lines

• Creative and Professional Design

#### 120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

###### 120+ PM Templates Includes:
• 50+ Excel Templates

• 50+ PowerPoint Templates

• 25+ Word Templates

Share Post

The VBA Pmt function is a financial function that calculates the periodic payment for a loan or investment with a fixed interest rate and fixed payment amount. It is commonly used in Excel and other spreadsheet applications to help individuals and organizations plan and manage their finances.

## VBA Pmt Function – Purpose, Syntax and Arguments

### Purpose:

The primary purpose of the Pmt function is to help users determine how much they need to pay for a loan or investment on a regular basis. This can be useful for both borrowers and lenders, as it allows them to accurately plan their cash flow and ensure that they can make the necessary payments on time.

### Syntax:

The syntax for the Pmt function is as follows:

=Pmt(rate, nper, pv, [fv], [type])

### Arguments:

• Rate: This is the interest rate per period for the loan or investment. It is usually expressed as a percentage, and can be an annual, monthly, or even daily rate, depending on the frequency of payments.
• Nper: This is the total number of payment periods for the loan or investment. It is typically expressed in years, but can also be in months, days, or any other unit as long as it is consistent with the rate argument.
• Pv: This is the present value, or current amount, of the loan or investment. It represents the initial amount borrowed or invested, and can be a positive or negative value.
• Fv (optional): This is the future value, or expected amount, of the loan or investment at the end of the payment periods. If omitted, the default value is 0.
• Type (optional): This specifies when the payments are due, either at the beginning (type = 1) or end (type = 0) of each period. If omitted, the default value is 0 (payments due at end of period).

### Example:

Suppose we want to calculate the monthly payment for a loan of \$10,000 with an annual interest rate of 5% and a term of 5 years. Using the Pmt function, the formula would be:

=Pmt(5%/12, 5*12, 10000)

This would give us a monthly payment of \$188.71, which is the amount we need to pay every month to fully pay off the loan within 5 years.

### Remarks and Important Notes:

• The Pmt function assumes that the payments are made at regular intervals and in equal amounts.
• Both the rate and nper arguments must be expressed in the same unit (e.g. if the rate is in annual percentage, nper must be in years).
• The Pmt function returns a negative value, as payments are considered outgoing cash flows.
• If the future value argument (fv) is omitted, it is assumed to be 0.
• If the type argument is omitted, it is assumed to be 0 (payments due at end of period).
• The function rounds the result to the nearest cent, and the precision can be adjusted using the VBA SetPrecision function.

## Understanding VBA Pmt Function with Examples

### Example 1: Simple Monthly Payment Calculation

Description: This example shows how the VBA Pmt function is used to calculate the monthly payment for a loan with a fixed interest rate.

Option Explicit
Sub calculateMonthlyPayment()
Dim principal As Double
Dim interestRate As Double
Dim loanPeriod As Integer
Dim monthlyPayment As Double
'Assign values to variables
principal = 10000
interestRate = 0.05
loanPeriod = 5
'Calculate monthly payment using Pmt function
monthlyPayment = Pmt(interestRate / 12, loanPeriod * 12, -principal)
'Print the result
Debug.Print "Your monthly payment is: ", monthlyPayment
End Sub
1. The first step is to declare all the necessary variables using the Dim statement.
2. Next, we assign values to the variables. In this example, we have taken a principal amount of \$10000, an annual interest rate of 5% and a loan period of 5 years.
3. In the third step, we use the Pmt function to calculate the monthly payment. The function takes three arguments – rate, nper and pmt.
4. The rate argument is the annual interest rate divided by 12, as we are calculating the monthly payment.
5. The nper argument is the total number of payment periods, which is equal to the loan period multiplied by 12.
6. The pmt argument is the present value or the principal amount, which is represented by a negative number.
7. The result of the Pmt function is assigned to the monthlyPayment variable.
8. Finally, we use the Debug.Print statement to display the result in the immediate window.

### Explanation:

The Pmt function is used to calculate the monthly payment for a loan, mortgage, or any other financial instrument with a fixed interest rate. The function follows the syntax Pmt(rate, nper, pmt), where each argument has a specific meaning.
The rate argument is the interest rate per period, which is the annual interest rate divided by the number of periods. For example, if the annual interest rate is 5%, the monthly interest rate would be 5%/12 = 0.05/12 = 0.004167. This converts the annual rate to its monthly equivalent.
The nper argument is the total number of payment periods for the loan. For a 5-year loan, the total number of payment periods would be 5*12 = 60, as there are 12 months in a year.
The pmt argument is the present value or the principal amount of the loan. This is represented by a negative number as it is the amount you owe or the amount you need to borrow.
The Pmt function returns a negative number, which represents the amount of money that needs to be paid each month to pay off the loan. In this example, the monthly payment comes out to be \$186.61.

### Example 2: Variable Loan Period and Interest Rate

Description: This example uses input from the user to calculate the monthly payment for a loan with variable loan period and interest rate.

Option Explicit
Sub calculateMonthlyPayment()
Dim principal As Double
Dim interestRate As Double
Dim loanPeriod As Integer
Dim monthlyPayment As Double
principal = InputBox("Enter the principal amount:")
interestRate = InputBox("Enter the annual interest rate:")
loanPeriod = InputBox("Enter the loan period in years:")
'Calculate monthly payment using Pmt function
monthlyPayment = Pmt(interestRate / 12, loanPeriod * 12, -principal)
'Print the result
Debug.Print "Your monthly payment is: ", monthlyPayment
End Sub
1. In this example, we have replaced the hard-coded values with input from the user. We use the InputBox function to prompt the user for input and assign the value to the respective variables.
2. The Pmt function is then used to calculate the monthly payment using the user-provided values.
3. The result is displayed in the immediate window using the Debug.Print statement.

### Explanation:

The InputBox function is used to get input from the user in the form of a string. In this example, we have used the function to get the principal amount, annual interest rate, and loan period in years. The input is then converted to a numerical value using the CDbl function and assigned to the corresponding variables.
The rest of the code works similarly to the previous example, where the Pmt function is used to calculate the monthly payment and display the result in the immediate window.

### Example 3: Calculating Total Interest Paid

Description: This example shows how the Pmt function can be used to calculate the total interest paid over the course of a loan.

Option Explicit
Sub calculateTotalInterestPaid()
Dim principal As Double
Dim interestRate As Double
Dim loanPeriod As Integer
Dim monthlyPayment As Double
Dim totalInterest As Double
'Assign values to variables
principal = 10000
interestRate = 0.05
loanPeriod = 5
'Calculate monthly payment using Pmt function
monthlyPayment = Pmt(interestRate / 12, loanPeriod * 12, -principal)
'Calculate total interest paid
totalInterest = monthlyPayment * (loanPeriod * 12) - principal
'Print the result
Debug.Print "Total interest paid: ", totalInterest
End Sub
1. In this example, we have added a new variable totalInterest to hold the value of the total interest paid.
2. After calculating the monthly payment using the Pmt function, we use a simple formula monthlyPayment * (loanPeriod * 12) – principal to calculate the total interest paid.
3. The result is then displayed in the immediate window using the Debug.Print statement.

### Explanation:

Calculating the total interest paid over the course of a loan can be useful in analyzing the cost of borrowing money. In this example, we first calculate the monthly payment using the Pmt function. Then, we multiply it by the total number of payment periods and subtract the principal amount from the result.

### Conclusion:

The Pmt function in VBA is a useful tool for calculating monthly payments for loans and other financial instruments. It takes into account the loan period, interest rate, and principal amount to determine the monthly payment. This function can be used in various scenarios, as shown in the examples above, to calculate the monthly payment, total interest paid, or other loan-related calculations.

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER

###### Project Portfolio Management Templates
Categories: VBA FunctionsLast Updated: September 30, 2023