The Excel NPER function calculates the number of periods required to pay off a loan, for a specified constant periodic payment and a constant interest rate.
The syntax of the function is :
Where the arguments are as follows:
rate    The interest rate, per period 
pmt    The amount paid per period 
pv    The present value of the loan 
[fv]   
An optional argument that specifies the future value of the loan, after the final payment If omitted, [fv] takes on the default value of 0 
[type]   
An optional argument that defines whether the payment is made at the start or the end of the period The type argument can have the value 0 or 1, meaning:0  the payment is made at the end of the period 1  the payment is made at the beginning of the period If the [type] argument is omitted, it takes on the default value of 0 (denoting payments made at the end of the period). 
In each of the examples below, the spreadsheet on the left shows the format of the Nper function, and the spreadsheet on the right shows the result.
The following spreadsheet shows the Excel Nper function used to calculate the number of months required to pay off in full, a loan of $50,000 at a rate of $1,000 per month. Interest is charged at a rate of 4% per year, and the payment to the loan is to be made at the end of each month.
Formulas:

Results:

Note that in this example :
In this example, the spreadsheet below shows the Excel Nper function used to calculate the number of quarterly payments of $1,200 that are required to reduce a loan of $9,000 to $5,000. Interest is charged at a rate of 6% per year and the payment to the loan is to be made at the beginning of each quarter.
Formulas:

Results:

Note that, in this example :
Further examples of the Excel Nper function can be viewed on the Microsoft Office website.
If you get an error from the Nper function, this is likely to be one of the following:
#NUM!    Occurs if the specified future value will never be met for the specified periodic interest rate and payments. You may need to increase the payment amount or reduce the interest rate to get a valid result. 
#VALUE!    Occurs if any of the supplied arguments are not recognised as numeric values. 
Also, the following problem is encountered by some users:
The Excel NPER function gives a negative result, when a positive one is expected.
This problem usually occurs when the present value and the specified periodic payment both have the same arithmetic sign. If a loan is being paid off, present value should be negative and the payment should be positive (or vice versa)
This problem can be avoided if you ensure that all signs adhere to the usual Cash Flow Sign Conventions