Trying to work with Date array but get a Run-time error '13'. Should I use Variant?
Private ppoolName As String
Private pissueDate As Date
Private pmatDate As Date
Private pcoupFreq As Integer
Private pWAC As Double
Private porigBal As Double
Private pcurrBal As Double
Private pcpnDate() As Date
Public Property Get cpnDate() As Date
cpnDate = pcpnDate
End Property
Public Property Let cpnDate(Value As Date)
pcpnDate = Value
End Property
Sub collateralInit(Valuation_Date As Date, collateralInput_ As collateralInput)
Me.coupFreq = collateralInput_.coupFreq
Me.currBal = collateralInput_.currBal
Me.issueDate = collateralInput_.issueDate
Me.matDate = collateralInput_.matDate
Me.cpnDate = GenCpnDates(Valuation_Date, Me.matDate, Me.coupFreq)
End Sub
Public Function GenPrevCpnDate(Price_Date As Date, Mature_Date As Date, Cpn_Freq As Integer) As Date
Dim CpnDates() As Date
Dim next_date As Date
Dim next_sch_date As Date
Dim last As Date
Dim d0 As Integer, m0 As Integer, y0 As Integer, add_m As Integer
Dim k As Integer
Dim HolidayRng As Range
'Set HolidayRng = Sheets("curves").Range("HolidayRng")
cpncount = 0
d0 = Day(Mature_Date)
m0 = Month(Mature_Date)
y0 = Year(Price_Date) - 1
next_date = DateValue(m0 & "/" & d0 & "/" & y0)
Select Case Cpn_Freq
Case 1
add_m = 12
Case 4
add_m = 3
Case 2
add_m = 6
Case 12
add_m = 1
Case Else
add_m = 3
End Select
' find the first cpndate
k = 1
Do
last = next_date ' save this previous cpn date
next_sch_date = FixDate(m0 + add_m * k, d0, y0)
next_date = NextWorkingDay(next_sch_date - 1) ' make sure it is a working day
k = k + 1
Loop Until next_date > Price_Date
GenPrevCpnDate = last
End Function
Bookmarks