modakindia
New Member
- Joined
- Mar 18, 2013
- Messages
- 4
I am getting the subject mentioned error while processing the following code:
Error coming at line: VResult = WorksheetFunction.Xirr(arrAmount, arrYears, Guess)
Please help.
Code:
Public Function CheckIRR1(Company As String, Term As Integer, Premium As Integer, ProposalDate As Date, YearlyInstalment As Integer, DateOfLastPayment As Date, DateOfMaturity As Date)
Dim nArraySize As Integer
nArraySize = (Term * YearlyInstalment) + 1
Dim VResult
Dim arrAmount() As Double
ReDim arrAmount(1 To nArraySize)
Dim arrYears() As Long
ReDim arrYears(1 To nArraySize)
Dim Guess As Double
Dim LoopDate As Date
LoopDate = ProposalDate
i = 1
Do While LoopDate <= DateOfMaturity
If i < nArraySize Then
arrAmount(i) = -Premium
End If
arrYears(i) = LoopDate
LoopDate = WorksheetFunction.EDate(LoopDate, 12 / YearlyInstalment)
i = i + 1
Loop
Guess = 0.1
VResult = WorksheetFunction.Xirr(arrAmount, arrYears, Guess)
MsgBox CStr(VResult)
End Function
Error coming at line: VResult = WorksheetFunction.Xirr(arrAmount, arrYears, Guess)
Please help.