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
| 'Fonction qui récupére les données bonne date et bon périmetre
Private Function DicoData(ByVal xlsheet As Worksheet, Optional limit As Boolean) As Dictionary
'Variables
Dim MyRange As Range, AllRange As Range
Dim MyDico As New Dictionary
Dim MyKey As String, MyObject As DataPnL
Dim MyDateVaR As Date, MyDateSVaR As Date
Dim MyRangeName As Range
'Affichage
Application.ScreenUpdating = False
'Determiner le range à parcourir
Set AllRange = xlsheet.Range(xlsheet.Range("C10"), xlsheet.Range("C10").End(xlDown))
'Limite pour le check histo
If limit Then
'Liste de Perimetres de test
With ThisWorkbook.Worksheets("HistoPnL")
Set MyRangeName = .Range(.Range("DateHisto"), .Range("DateHisto").End(xlToRight)).Offset(-1)
End With
'Parcours de la feuille
For Each MyRange In AllRange
'Clef
If Not MyRangeName.Find(MyRange.Value) Is Nothing Then
MyKey = MyRange.Value & "_" & MyRange.Offset(, -1).Value
If Not MyDico.Exists(MyKey) Then
Set MyObject = New DataPnL
MyObject.Daily = MyRange.Offset(, 5).Value * MyRange.Offset(, 4).Value / 1000000
MyObject.MtD = MyRange.Offset(, 6).Value * MyRange.Offset(, 4).Value / 1000000
MyObject.YtD = MyRange.Offset(, 7).Value * MyRange.Offset(, 4).Value / 1000000
MyDico.Add MyKey, MyObject
Debug.Print MyKey
End If
End If
Next MyRange
Else:
For Each MyRange In AllRange
'Clef
MyKey = MyRange.Value & "_" & MyRange.Offset(, -1).Value
If Not MyDico.Exists(MyKey) Then
Set MyObject = New DataPnL
MyObject.Daily = MyRange.Offset(, 5).Value * MyRange.Offset(, 4).Value / 1000000
MyObject.MtD = MyRange.Offset(, 6).Value * MyRange.Offset(, 4).Value / 1000000
MyObject.YtD = MyRange.Offset(, 7).Value * MyRange.Offset(, 4).Value / 1000000
MyDico.Add MyKey, MyObject
Debug.Print MyKey
End If
Next MyRange
End If
'Asignation
Set DicoData = MyDico
'Dictionnaire
Set MyDico = Nothing
End Function |
Partager