Hey guys, looking for some help on proper syntax for creating a function in the VBE of Excel. My apologies ahead of time, I am extremely new to this and the below problem is part of a Coursera course I am taking:



When a loan of principal amount, P, is taken at an annual interest rate iwith a repayment period of n years, the following equation provides the monthly payment, A:

FY1-6LYLEeiu9BLDf-7i5A_b9833a7ad547b30f277ed1717c0566bd_payment.png

Create a VBA function called payment(P,i,n) that will output the monthly payment (A) based on the principal, annual interest rate, and lifetime of the loan.

To check your answer, the monthly payment on a 20-year loan with principle $10,000 with an annual interest rate of 4.5% would be $63.26.



The way I wrote this function is below. When I try to run it, I get a "Compile error: Expected Array" error message. I know what I have is incorrect, just need help figuring it out:

Function payment(P As Double, i As Double, n As Double) As Double
Dim A As Double
A = (P(i / 12)) / (1 - (1 + (i / 12))) ^ (-n * 12)
payment = A
End Function