The Excel NPER function calculates the number of periods required to pay off a loan, for a 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; 
Cash Flow Convention:
Note that, in line with the general cash flow convention, outgoing payments are represented by negative numbers and incoming payments are represented by positive numbers. This is seen in the examples below.In the following spreadsheet, the Excel Nper function is 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.
Formula:

Result:

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.
Formula:

Result:

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