tadIKVwerte(werte; wachstum; schätzwert; compoundierung)
Compoundierung
1 = Jahr
1/2 = Halbjahres
1/4 = vierteljährlich
1/12 = monatlich
1/52 = wöchentlich
1/365 = täglich
0 = unendlich
2 = zweijährig
-----------------------------------------------------------------
[code]
Public Function tadEFFEKTIVE(ByVal zins As Double, ByVal compoundierung As Double)
If compoundierung = 0 Then
tadEFFEKTIVE = Exp(zins) - 1
Else
tadEFFEKTIVE = (1 + zins * compoundierung) ^ (1 / compoundierung) - 1
End If
End Function
Public Function tadAUF(ByVal zins As Double, ByVal N As Double, ByVal compoundierung As Double)
tadAUF = (1 + tadEFFEKTIVE(zins, compoundierung)) ^ (N)
End Function
Public Function tadABF(ByVal zins As Double, ByVal N As Double, ByVal compoundierung As Double)
tadABF = (1 + tadEFFEKTIVE(zins, compoundierung)) ^ (-N)
End Function
Public Function tadABFbar(ByVal zins As Double, ByVal N As Double, ByVal compoundierung As Double)
If (compoundierung = 0) Then
tadABFbar = -N * tadABF(zins, N, compoundierung)
Else
tadABFbar = -N / compoundierung * tadABF(zins, N, compoundierung)
End If
End Function
Public Function tadKAPITALWERT(ByVal zins As Double, ByVal wachstum As Double, ByVal Werte As Range, ByVal compoundierung As Double) As Double
Dim rCell As Range
Dim i As Long
Dim t As Double
Dim kapitalwert As Double
Dim WerteArr() As Double
Dim f As Double
Dim fn As Double
Dim fd As Double
ReDim WerteArr(Werte.Count - 1)
i = 0
For Each rCell In Werte.Cells
WerteArr(i) = rCell.Value
i = i + 1
Next rCell
kapitalwert = 0
For i = 0 To Werte.Count - 2
t = i
kapitalwert = kapitalwert + WerteArr(i) * tadABF(zins, t, compoundierung)
Next i
t = Werte.Count - 2
fn = WerteArr(Werte.Count - 1) * tadABF(zins, t, compoundierung)
fd = tadEFFEKTIVE(zins, compoundierung) - tadEFFEKTIVE(wachstum, compoundierung)
f = fn / fd
kapitalwert = kapitalwert + f
tadKAPITALWERT = kapitalwert
End Function
Public Function tadKAPITALWERTbar(ByVal zins As Double, ByVal wachstum As Double, ByVal Werte As Range, ByVal compoundierung As Double) As Double
Dim rCell As Range
Dim i As Long
Dim t As Double
Dim kapitalwert As Double
Dim WerteArr() As Double
Dim fbar As Double
Dim fn As Double
Dim fd As Double
Dim fnbar As Double
Dim fdbar As Double
ReDim WerteArr(Werte.Count - 1)
i = 0
For Each rCell In Werte.Cells
WerteArr(i) = rCell.Value
i = i + 1
Next rCell
kapitalwert = 0
For i = 0 To Werte.Count - 2
t = i
kapitalwert = kapitalwert + WerteArr(i) * tadABFbar(zins, t + compoundierung, compoundierung)
Next i
t = Werte.Count - 2
fn = WerteArr(Werte.Count - 1) * tadABF(zins, t, compoundierung)
fnbar = WerteArr(Werte.Count - 1) * tadABFbar(zins, t + compoundierung, compoundierung)
fd = tadEFFEKTIVE(zins, compoundierung) - tadEFFEKTIVE(wachstum, compoundierung)
fdbar = tadAUF(zins, 1-compoundierung, compoundierung)
fbar = (fd * fnbar - fn * fdbar) / fd ^ 2
kapitalwert = kapitalwert + fbar
tadKAPITALWERTbar = kapitalwert
End Function
Public Function tadIKVwerte(ByVal Werte As Range, ByVal wachstum As Double, ByVal schätzwert As Double, ByVal compoundierung As Double) As Double
Dim f As Double
Dim fbar As Double
Dim x As Double
Dim x0 As Double
Dim i As Integer
Dim found As Integer
found = 0
x0 = schätzwert
Do While (i < 100)
f = tadKAPITALWERT(x0, wachstum, Werte, compoundierung)
fbar = tadKAPITALWERTbar(x0, wachstum, Werte, compoundierung)
If (fbar = 0) Then
tadIKVwerte = (0) ^ (-1)
Else
x = x0 - f / fbar
End If
If (Abs(x - x0) < 0.000001) Then
found = 1
Exit Do
End If
x0 = x
i = i + 1
Loop
If (found = 1) Then
tadIKVwerte = x
Else
tadIKVwerte = (-1) ^ (0.5)
End If
End Function
[/code]