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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
| Public nlast_harmonie, nlast_projet As Long
Public nfirst_harmonie As Integer
Public date_extraction As Date
Public harmonie As Worksheet
Public projet As Worksheet
Public check As Worksheet
Public taux As Worksheet
Public cell As Range
Public Sub initialise0()
Set harmonie = Sheets("Extractions Harmonie")
Set projet = Sheets("Projets")
Set taux = Sheets("Taux de change")
Set check = Sheets("Checking")
'Dernière ligne Extraction Harmonie
nlast_harmonie = harmonie.Range("A" & Rows.Count).End(xlUp).Row
nlast_projet = projet.Range("A" & Rows.Count).End(xlUp).Row
'Initialisation de la date d'extraction
date_extraction = harmonie.Range("A" & nlast_harmonie)
'identification de la première ligne de l'extraction harmonie
For i = 6457 To nlast_harmonie
If harmonie.Cells(i, 1) = date_extraction Then
nfirst_harmonie = i
Exit For
End If
Next
check.Range("C1") = nfirst_harmonie
check.Range("C2") = nlast_harmonie
End Sub
Public Sub MiseAjour()
'
' Cette macro met à jour l'onglet "Taux de change" et uniformise le format
' des lignes de l'onglet "Extractions Harmonie"
'
Application.ScreenUpdating = False
'Initialisation des variables
initialise0
'Uniformisation du format et de la taille des lignes dans l'Extraction Harmonie
harmonie.Range("A6458:AY6458").Copy ' cette ligne est prise en référence car elle possède un format standard
harmonie.Rows(nfirst_harmonie & ":" & nlast_harmonie).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
harmonie.Rows(nfirst_harmonie & ":" & nlast_harmonie).RowHeight = 17.75
' Suppression des "0000" sur les BDM ID
harmonie.Range("C" & nfirst_harmonie & ":C" & nlast_harmonie).Replace _
What:="0000", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Range("A" & nlast_harmonie).Select
'Mise à jour des dates et des taux de change dans l'onglet "Taux"
If taux.Range("D3") <> harmonie.Range("A" & nlast_harmonie) Then
For Each cell In taux.Range("D3:D13")
taux.Range("C" & cell.Row) = cell.Value
taux.Range("D3") = date_extraction
Next cell
'Mise à jour des Taux de change à la date d'extraction
For Each cell In taux.Range("B4:B13")
taux.Range("D" & cell.Row) = MARECHV(nfirst_harmonie, cell.Value, 40, 41)
Next cell
End If
Application.ScreenUpdating = True
End Sub
Public Sub checking()
'Variables
Dim A1, A2, A3, A4 As String
Dim n, m As Integer
Application.ScreenUpdating = False
Initialize
'Initialisation des variable
initialise0
'recherche des anomalies (données non retombées dans Harmonie)
A1 = "Pays TRR"
A2 = "Méthodologie de notation"
A3 = "LGD ID"
A4 = "Nature of cash flows"
n = 0
m = 0
'Anomalie Pays TRR
For Each cell In harmonie.Range("AX" & nfirst_harmonie & ":AX" & nlast_harmonie)
If cell = "" Then
check.Rows(14 + n & ":" & 14 + n).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
check.Range("B" & 12 + n) = harmonie.Range("C" & cell.Row) 'BDM ID
check.Range("C" & 12 + n) = harmonie.Range("D" & cell.Row) 'Libellé
check.Range("D" & 12 + n) = harmonie.Range("AD" & cell.Row) 'Réf limite
check.Range("E" & 12 + n) = cell.Row 'N° de la ligne
check.Range("F" & 12 + n) = A1 'Nature de l'anomalie
n = n + 1
End If
Next cell
'Anomalie Méthodologie de notation
For Each cell In harmonie.Range("AY" & nfirst_harmonie & ":AY" & nlast_harmonie)
If cell = "" Then
check.Rows(14 + n & ":" & 14 + n).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
check.Range("B" & 12 + n) = harmonie.Range("C" & cell.Row) 'BDM ID
check.Range("C" & 12 + n) = harmonie.Range("D" & cell.Row) 'Libellé
check.Range("D" & 12 + n) = harmonie.Range("AD" & cell.Row) 'Réf limite
check.Range("E" & 12 + n) = cell.Row 'N° de la ligne
check.Range("F" & 12 + n) = A2 'Nature de l'anomalie
n = n + 1
End If
Next cell
'Anomalie LGD ID
For Each cell In harmonie.Range("G" & nfirst_harmonie & ":G" & nlast_harmonie)
If cell = "" Then
check.Rows(14 + n & ":" & 14 + n).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
check.Range("B" & 12 + n) = harmonie.Range("C" & cell.Row) 'BDM ID
check.Range("C" & 12 + n) = harmonie.Range("D" & cell.Row) 'Libellé
check.Range("D" & 12 + n) = harmonie.Range("AD" & cell.Row) 'Réf limite
check.Range("E" & 12 + n) = cell.Row 'N° de la ligne
check.Range("F" & 12 + n) = A3 'Nature de l'anomalie
n = n + 1
End If
Next cell
'Anomalie Nature of cash flows
For Each cell In harmonie.Range("N" & nfirst_harmonie & ":N" & nlast_harmonie)
If cell = "" Then
check.Rows(14 + n & ":" & 14 + n).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
check.Range("B" & 12 + n) = harmonie.Range("C" & cell.Row)
check.Range("C" & 12 + n) = harmonie.Range("D" & cell.Row)
check.Range("D" & 12 + n) = harmonie.Range("AD" & cell.Row)
check.Range("E" & 12 + n) = cell.Row
check.Range("F" & 12 + n) = A4
n = n + 1
End If
Next cell
'Deal ne retombant pas dans Harmonie
For Each cell In projet.Range("A3:A" & nlast_projet)
If MARECHV(nfirst_harmonie, cell, 3, 3) = "" Then
If n < m Then
check.Rows(14 + m & ":" & 14 + m).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
check.Range("H" & 12 + m) = projet.Range("A" & cell.Row)
check.Range("I" & 12 + m) = projet.Range("B" & cell.Row)
m = m + 1
End If
Next
'Deal ne retombant pas dans projets
m = 0
For Each cell In harmonie.Range("C" & nfirst_harmonie & ":C" & nlast_harmonie)
If MARECHV(3, cell, 1, 1, "Projets") = "" Then
If n < m Then
check.Rows(14 + m & ":" & 14 + m).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
check.Range("K" & 12 + m) = harmonie.Range("C" & cell.Row)
check.Range("L" & 12 + m) = harmonie.Range("D" & cell.Row)
check.Range("M" & 12 + m) = cell.Row
m = m + 1
End If
Next
Application.ScreenUpdating = True
End Sub
Sub renseignement_valeurs()
'
Application.ScreenUpdating = False
'Importation des données
'Pays TRR
For Each cell In projet.Range("a3:A" & nlast_projet)
projet.Range("C" & cell.Row).Value = MARECHV(nfirst_harmonie, cell.Value, 3, 50)
Next cell
'Méthodologiede Notation
For Each cell In projet.Range("a3:A" & nlast_projet)
projet.Range("D" & cell.Row).Value = MARECHV(nfirst_harmonie, cell.Value, 3, 51)
Next cell
'LGD ID
For Each cell In projet.Range("a3:A" & nlast_projet)
projet.Range("F" & cell.Row).Value = MARECHV(nfirst_harmonie, cell.Value, 3, 7)
Next cell
'Nature of Cash flows
For Each cell In projet.Range("a3:A" & nlast_projet)
projet.Range("K" & cell.Row).Value = MARECHV(nfirst_harmonie, cell.Value, 3, 14)
Next cell
Application.ScreenUpdating = True
End Sub
Sub Initialize()
Dim nlast1, nlast2, nlast As Long
Set check = Sheets("Checking")
If check.Range("E12") <> "" Or check.Range("H12") <> "" Or check.Range("I12") <> "" Or check.Range("M12") <> "" Then
nlast1 = check.Range("E12").End(xlDown).Row
nlast2 = check.Range("M12").End(xlDown).Row
nlast = Application.Max(nlast1, nlast2)
check.Range("B12:N12").ClearContents
check.Range("B12:N" & nlast).Delete Shift:=xlUp
Range("C12").Select
End If
End Sub
Function MARECHV(ByVal nfirst As Integer, ByVal valeur_cherchee, ByVal num_colonne_de_rech As Integer, ByVal num_colonne_valeur_retournee As Integer, Optional feuille)
Dim last As Long
Dim mysheet As Worksheet
'Initialisation de la feuille de recherche
If IsMissing(feuille) Then
Set mysheet = Sheets("Extractions Harmonie")
Else
Set mysheet = Sheets(feuille)
End If
last = mysheet.Range("A" & Rows.Count).End(xlUp).Row
MARECHV = ""
For i = nfirst To last
If mysheet.Cells(last + nfirst - i, num_colonne_de_rech) = valeur_cherchee Then
If mysheet.Cells(last + nfirst - i, num_colonne_valeur_retournee) <> "" Then
MARECHV = mysheet.Cells(last + nfirst - i, num_colonne_valeur_retournee)
Exit For
End If
End If
Next
End Function |
Partager