For l = 1 To WVL_NbrePTF
If TABL_ListePTF(l, 1) = "x" Then
Workbooks(NAME_FILE).Sheets("MENU" ).Select
Range("C18" ).Value = TABL_ListePTF(l, 2)
Range("G17:G18,G20:G22,G24:G26,J29,J31,K29,K31" ).Select
Selection.ClearContents
Range("E12" ).Select
Workbooks(NAME_FILE).Sheets("Data" ).Select
Range("A3:S3" ).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A2" ).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("H2" ).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("O2" ).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
If Range("S3" ).Value = 0 Or Range("S3" ).Value = 1 Then
WVL_TypeSous = "SOUSCR"
WVL_TypeRach = "RACHAT"
Else
WVL_TypeSous = "APPORT"
WVL_TypeRach = "RETRAIT"
End If
'========================================
' ACHATS, VENTES
'========================================
WVL_NbreLignes = Application.CountA(Range("A:A" )) - 2
WVL_TotalAchat = 0
WVL_TotalVente = 0
For i = 1 To WVL_NbreLignes
If Cells(i + 2, 3).Value = "ACHAT" Then
WVL_TotalAchat = WVL_TotalAchat + Cells(i + 2, 4).Value
ElseIf Cells(i + 2, 3).Value = "VENTE" Then
WVL_TotalVente = WVL_TotalVente + Cells(i + 2, 4).Value
End If
Next
'========================================
' SOUSCRIPTIONS, RACHATS
'========================================
WVL_NbreLignes = Application.CountA(Range("H:H" )) - 2
If WVL_NbreLignes <= 0 Then
WVL_NbreLignes = 1
End If
ReDim TABL_DataSousRach(1 To WVL_NbreLignes, 1 To 3)
For i = 1 To WVL_NbreLignes
For c = 1 To 3
TABL_DataSousRach(i, c) = Cells(i + 2, c + 8).Value
Next
Next
For j = 1 To WVL_NbreLignes
If j = 1 Then
WVL_Compt = 1
ReDim WVL_Dates(1 To WVL_Compt)
WVL_Dates(WVL_Compt) = TABL_DataSousRach(j, 1)
ElseIf j <> 1 And TABL_DataSousRach(j, 1) <> TABL_DataSousRach(j - 1, 1) Then
WVL_Compt = WVL_Compt + 1
ReDim Preserve WVL_Dates(1 To WVL_Compt)
WVL_Dates(WVL_Compt) = TABL_DataSousRach(j, 1)
End If
Next
ReDim TABL_Souscriptions(1 To WVL_Compt, 1 To 2)
ReDim TABL_Rachats(1 To WVL_Compt, 1 To 2)
WVL_Next = 1
WVL_Boucle = 1
Do While WVL_Next <= WVL_Compt
For i = WVL_Boucle To WVL_NbreLignes
If TABL_DataSousRach(i, 1) = WVL_Dates(WVL_Next) Then
If TABL_DataSousRach(i, 2) = WVL_TypeSous Then
TABL_Souscriptions(WVL_Next, 2) = TABL_Souscriptions(WVL_Next, 2) + TABL_DataSousRach(i, 3)
TABL_Souscriptions(WVL_Next, 1) = WVL_Dates(WVL_Next)
ElseIf TABL_DataSousRach(i, 2) = WVL_TypeRach Then
TABL_Rachats(WVL_Next, 2) = TABL_Rachats(WVL_Next, 2) + TABL_DataSousRach(i, 3)
TABL_Rachats(WVL_Next, 1) = WVL_Dates(WVL_Next)
End If
Else
WVL_Next = WVL_Next + 1
WVL_Boucle = i
GoTo SUIVANT
End If
If WVL_Next = WVL_Compt And i = WVL_NbreLignes Then
GoTo FIN_BOUCLE
End If
Next
SUIVANT: Loop
FIN_BOUCLE: ReDim TABL_SousRachNET(1 To WVL_Compt, 1 To 2)
WVL_TotalSousRachNET = 0
For j = 1 To WVL_Compt
WVL_Souscription = WVL_Souscription + TABL_Souscriptions(j, 2) '## Total Souscriptions ##
WVL_Rachat = WVL_Rachat + TABL_Rachats(j, 2) '## Total Rachats ##
TABL_SousRachNET(j, 1) = WVL_Dates(j)
TABL_SousRachNET(j, 2) = TABL_Souscriptions(j, 2) + TABL_Rachats(j, 2)
WVL_TotalSousRachNET = WVL_TotalSousRachNET + Abs(TABL_SousRachNET(j, 2))
Next
'----------------------------------------------------------------------------
WVL_NbreLignes = Application.CountA(Range("O:O" )) - 2
WVL_ValoPTF1 = 0
WVL_Compt = 0
For i = 1 To WVL_NbreLignes
If Cells(i + 2, 17).Value <> "" Then
WVL_ValoPTF1 = WVL_ValoPTF1 + Cells(i + 2, 17).Value
Else
WVL_Compt = WVL_Compt + 1
End If
Next
WVL_NbreJours = 0
WVL_TurnOver_Min = 0
WVL_TurnOver_AMF = 0
WVL_NbreJours = (WVL_Datefin - WVL_DateDebut) + 1
WVL_ActifMoyen = WVL_ValoPTF1 / WVL_NbreJours
If WVL_ActifMoyen <> 0 Then
WVL_TurnOver_Min = (Abs(WorksheetFunction.Min(Abs(WVL_TotalAchat), Abs(WVL_TotalVente)) - WVL_TotalSousRachNET)) / WVL_ActifMoyen
WVL_TurnOverYear_Min = WVL_TurnOver_Min * (365 / WVL_NbreJours)
WVL_TurnOver_AMF = (Abs(WVL_TotalAchat) + Abs(WVL_TotalVente) - WVL_TotalSousRachNET) / WVL_ActifMoyen
WVL_TurnOverYear_AMF = WVL_TurnOver_AMF * (365 / WVL_NbreJours)
Else
WVL_TurnOver_Min = (Abs(WorksheetFunction.Min(Abs(WVL_TotalAchat), Abs(WVL_TotalVente)) - WVL_TotalSousRachNET))
WVL_TurnOverYear_Min = WVL_TurnOver_Min * (365 / WVL_NbreJours)
WVL_TurnOver_AMF = (Abs(WVL_TotalAchat) + Abs(WVL_TotalVente) - WVL_TotalSousRachNET)
WVL_TurnOverYear_AMF = WVL_TurnOver_AMF * (365 / WVL_NbreJours)
End If
'==============================================
' Ouvrir Classeur, enregistrer sous + écriture
'==============================================
Workbooks(WVL_NameFile).Activate
If WVL_TempLignes = 12 Then
Cells(10, 4).Value = WVL_DateDebut & " au " & WVL_Datefin
End If
Cells(WVL_TempLignes, 2).Value = TABL_ListePTF(l, 2)
Cells(WVL_TempLignes, 3).Value = TABL_ListePTF(l, 3)
Cells(WVL_TempLignes, 4).Value = WVL_TurnOverYear_AMF 'Format(WVL_TurnOverYear_AMF, "0.00%" )
Cells(WVL_TempLignes, 5).Value = WVL_TurnOverYear_Min 'Format(WVL_TurnOverYear_Min, "0.00%" )
WVL_TempLignes = WVL_TempLignes + 1
'==============================================
Workbooks(NAME_FILE).Sheets("MENU" ).Activate
Range("G17" ).Value = Abs(WVL_TotalAchat)
Range("G18" ).Value = Abs(WVL_TotalVente)
Range("G20" ).Value = Abs(WVL_Souscription)
Range("G21" ).Value = Abs(WVL_Rachat)
Range("G22" ).Value = WVL_Souscription + WVL_Rachat
Range("G24" ).Value = WVL_ValoPTF1
Range("G26" ).Value = WVL_ActifMoyen
Range("J29" ).Value = Format(WVL_TurnOver_Min, "0.00%" )
Range("J31" ).Value = Format(WVL_TurnOverYear_Min, "0.00%" )
Range("K29" ).Value = Format(WVL_TurnOver_AMF, "0.00%" )
Range("K31" ).Value = Format(WVL_TurnOverYear_AMF, "0.00%" )
Workbooks(NAME_FILE).Sheets("MENU" ).Select
Range("C18" ).Select
End If
Next