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
| Sub Test()
If MasquePivotTdc(ActiveSheet.PivotTables("PageTDC"), "Nom", "(blank);(vide);BOF;(BOFBOF)") = False Then MsgBox "Pas trouvé"
End Sub
Function MasquePivotTdc(TDC As Object, Champ As String, V As String) As Boolean
Dim t
Dim iTdc As Integer
Dim iT As Integer
Dim Trouve As Boolean
MasquePivotTdc = True
t = Split(V & ";", ";")
On Error GoTo Fin
For iT = 0 To UBound(t)
Trouve = False
If Trim("" & t(iT)) <> "" Then
For iTdc = 1 To TDC.PivotFields(Champ).PivotItems.Count
If Trim("" & TDC.PivotFields(Champ).PivotItems(iTdc).Name) = Trim("" & t(iT)) Then Trouve = True: Exit For
Next
If Trouve = True Then TDC.PivotFields(Champ).PivotItems(iTdc).Visible = False
End If
Next
On Error GoTo 0
Exit Function
Fin:
MasquePivotTdc = False
On Error GoTo 0
End Function |
Partager