Link to home
Start Free TrialLog in
Avatar of appc
appc

asked on

Error with custom VBA function

I get no error when I debug the function in VB but I get an error when I use the function...

Can someone help me?

Here is the code:

Function Amortization(Original As Double, Amort As Double, Months As Double, Rate As Double)
   
    Dim Previous As Double
    Dim Total As Double
    Dim i As Integer
   
    Previous = 0
   
    For i = 1 To Months
                       
                        Total = (Original - Amort * (i - 1)) / ((1 + Rate) ^ i) + Previous
       
        Previous = Total
   
    Next i
   
    End
   
        Amortization = Total
   
End Function
Avatar of JonMny
JonMny

when you get the error what is it?
SOLUTION
Avatar of omgang
omgang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of appc

ASKER

I get it in the spreadsheet:

#value!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Remove the single "End"
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of appc

ASKER

It worked. Thanks!