Bonjour à tous,

J'essaie d'adapté le code de cette discussion à mon projet, mais je rencontre certains bug ("Incompatibilité de type)

La sélection des PivotItems Année, mois et section se fait à partir de 3 ComboBox.

Est ce que vous pouvez regarder et m'aider à corriger mon code.

Ci dessous le code.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Private Sub Afficher_Click()
'Exportation des données sélectionnées dans une nouvelle feuille
Dim PVT_Année As PivotField, PVT_Mois As PivotField, PVT_Section As PivotField
Dim Tb
Dim i As Integer
 
Application.ScreenUpdating = False
Tb = Rapport.ComboBox2.Value And Rapport.ComboBox3.Value And Rapport.ComboBox1.Value
Set PVT_Année = Worksheets("Rapport").PivotTables("TCD8").PivotFields("ANNEE")
Set PVT_Mois = Worksheets("Rapport").PivotTables("TCD8").PivotFields("MOIS")
Set PVT_Section = Worksheets("Rapport").PivotTables("TCD8").PivotFields("SECTION")
With PVT
    .ClearAllFilters
    .EnableMultiplePageItems = True
    On Error Resume Next
    .PivotItems(Tb(1, 1)).Visible = True
    For i = 1 To PivotItems.Count
        .PivotItems(i).Visible = .PivotItems(i) = Tb(1, 1) Or Not .PivotItems(i).Visible
    Next i
    For i = 2 To UBound(Tb)
        .PivotItems(Tb(i, 1)).Visible = True
    Next i
End With
Set PVT = Nothing
    Worksheets("Rapport").Activate
    Suivi.Hide
 
End Sub
Merci par avance