Advertisement
Advertisement
| 07.23.2008 at 01:52PM PDT, ID: 23590160 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: |
Option Compare Database
Function XIRR(aXIRR As Variant, nRate As Double, nPayments As Integer) As Double
Dim i As Integer
XIRR = 0 ' residual of function
For i = 1 To nPayments
XIRR = XIRR + aXIRR(i, 2) / (1 + nRate) ^ (aXIRR(i, 1) / 365)
Next i
End Function
Private Sub CommandRunXIRR_Click()
Dim dbs As Database
Dim rstXIRR As Recordset
Dim aXIRR() As Double
Dim nPayments As Integer
Dim dFirstPayDate As Date
Dim i As Integer, j As Integer
Dim nRate As Double, nLastRate As Double, nRateStep As Double
Dim nXIRR As Double
Dim nResidual As Double, nLastResidual As Double
Set dbs = CurrentDb
Set rstXIRR = dbs.OpenRecordset("TableXIRR", dbOpenDynaset)
nPayments = DCount("PayDate", "TableXIRR")
ReDim aXIRR(nPayments, 3)
dFirstPayDate = DMin("PayDate", "TableXIRR")
nRate = 0.1 ' initial guess
nRateStep = 0.1 ' arbitrary guess
i = 1
With rstXIRR
While Not .EOF
aXIRR(i, 1) = DateDiff("d", dFirstPayDate, !PayDate)
aXIRR(i, 2) = !Payment
i = i + 1
.MoveNext
Wend
End With
nResidual = 10
nLastResidual = 1
nLastRate = nRate
i = 0
While i < 100 And Abs((nLastResidual - nResidual) / nLastResidual) > 10 ^ -8
nLastResidual = nResidual
nResidual = XIRR(aXIRR, nRate, nPayments)
nLastRate = nRate
If nResidual >= 0 Then
nRate = nRate + nRateStep
Else
nRateStep = nRateStep / 2
nRate = nRate - nRateStep
End If
i = i + 1
Wend
nXIRR = nLastRate
Debug.Print "The internal rate of return is "; Format(nXIRR, "#.##%")
End Sub
|