Habe folgenden VBA code geschrieben:
Function MyPrice(settlement As Date, maturity As Date, rate, spots, notional, freq As Integer, Optional compound As Integer, _
Optional fromdate As Date, Optional basis As Integer)
' Determines present value of bond cash flows accruing after fromdate
Dim t As Date, y As Double
' Set default values and some error checking
If compound = 0 Then compound = freq
If fromdate = 0 Then fromdate = settlement
If fromdate > maturity Or settlement > maturity Then End
'Determine PV of payment at maturity
t = maturity
y = YearFrac(settlement, maturity, basis)
MyPrice = (notional + notional * rate / freq) / _
(1 + INTSPOT(spots, y) / compound) ^ (y * compound)
'Add PVs of coupon payments
t = CoupPcd(t - 1, maturity, freq, basis)
Do While t > settlement And t > fromdate
y = YearFrac(settlement, t, basis)
MyPrice = MyPrice + rate / freq * notional / _
(1 + INTSPOT(spots, y) / compound) ^ (y * compound)
t = CoupPcd(t - 1, maturity, freq, basis)
Loop
End Function
Leider funktioniert das Makro nicht, da die Funktion yearfrac nicht definiert ist. Daraufhin habe ich im Internet gesucht und im Menü unter tools die Reference atpvbaen.xls zu aktivieren versucht? Leider kommt es hierzu dann zu einem Fehler in VBA (fehler 400). Kann mir jemand weiterhelfen, wie ich das Makro aktivieren kann?
|