Resalut,
J'ai ce code qui me permet de garder dans mon TCD seulement le mois de la date du jour :
Sub ThisMonth_Filter()
'Variable declaration
Dim strMonth As String
Dim strMonthNow As String
Dim X As Object
Dim Y As String
Y = Month(Now) 'Takes the month of today
strMonthNow = Choose(Y, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
With Sheets("Safety & Airworthiness actions").PivotTables("S_PivotTable").PivotFields("Month") 'Active filter just on this array and this filter
For Each X In Sheets("Safety & Airworthiness actions").PivotTables("S_PivotTable").PivotFields("Month").PivotItems 'Read each field of the filter and go through them
'strMonth = X 'Stock the month in a String variable
strMonth = Choose(X, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
If .PivotItems(strMonth) <> .PivotItems(strMonthNow) Then 'if the filter date is different from the current date
.PivotItems(strMonth).Visible = False 'Puts the filter inactive
.PivotItems(strMonthNow).Visible = True
End If
Next
End With
End Sub
Seulement la boucle if semble être le problème mais je ne comprends absolument pas pourquoi ...
Si vous pouviez m'aider ...
Merci