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
|
Function RetainRating(ERRating As String, MoodysRating As String, FitchRating As String, DBRSRating As String, SPRating As String) As String
'Returns the retain rating
'Formating ERrating notation
If Left(ERRating, 1) = "i" Then
EIFRating = Right(ERRating, Len(ERRating) - 1)
End If
'Converting from Fitch SP ER DBRS Moody's Rating to scale
Dim i As Integer, j As Integer, UB As Integer, LB As Integer, test As Integer
Dim SPRatings As Variant, FitchRatings As Variant, DBRSRatings As Variant, MoodysRatings As Variant, ERRatings As Variant, Ratings As Variant
SPRatings = Array("AAA", "AA+", "AA", "AA-", "A+", "A", "A-", "BBB+", "BBB", "BBB-", "BB+", "BB", "BB-", "B+", "B", "B-", "CCC+", "CCC", "CCC-", "NR")
FitchRatings = Array("AAA", "AA+", "AA", "AA-", "A+", "A", "A-", "BBB+", "BBB", "BBB-", "BB+", "BB", "BB-", "B+", "B", "B-", "CCC+", "CCC", "CCC-", "NR")
DBRSRatings = Array("AAA", "AA(High)", "AA", "AA(Low)", "A(High)", "A", "A(Low)", "BBB(High)", "BBB", "BBB(Low)", "BB(High)", "BB", "BB(Low)", "B(High)", "B", "B(Low)", "CCC(High)", "CCC", "CCC(Low)", "NR")
MoodysRatings = Array("Aaa", "Aa1", "Aa2", "Aa3", "A1", "A2", "A3", "Baa1", "Baa2", "Baa3", "Ba1", "Ba2", "Ba3", "B1", "B2", "B3", "Caa1", "Caa2", "Caa3", "NR")
Ratings = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "0")
UB = UBound(Ratings)
LB = LBound(Ratings)
Dim T()
Dim cpt& 'compteur
For j = LB To UB
If ERRating = CStr(MoodysRatings(j)) Then
cpt = cpt + 1
ReDim Preserve T(1 To cpt)
T(cpt) = Ratings(j)
End If
If MoodysRating = CStr(MoodysRatings(j)) Then
cpt = cpt + 1
ReDim Preserve T(1 To cpt)
T(cpt) = Ratings(j)
End If
If FitchRating = CStr(FitchRatings(j)) Then
cpt = cpt + 1
ReDim Preserve T(1 To cpt)
T(cpt) = Ratings(j)
End If
If DBRSRating = CStr(DBRSRatings(j)) Then
cpt = cpt + 1
ReDim Preserve T(1 To cpt)
T(cpt) = Ratings(j)
End If
If SPRating = CStr(SPRatings(j)) Then
cpt = cpt + 1
ReDim Preserve T(1 To cpt)
T(cpt) = Ratings(j)
End If
Next j
RetainRating = Application.WorksheetFunction.Small(T, 2)
For j = LB To UB
If RetainRating = CStr(Ratings(j)) Then
RetainRating = MoodysRatings(j)
End If
Next j
End Function |