comment filtrer 2 TCD en meme temps

isabe

XLDnaute Nouveau
Bonjour,
j'ai x TCD (entre 2 et 10), de sources differentes, mais ayant tout de meme des filtres communs.
comment faire pour appliquer le meme filtre sur tous les tcd?

j'ai essayé avec ça

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim ws As Worksheet
Dim pt As PivotTable
Dim pi As PivotItem
Dim strField As String
Dim strField2 As String

strField = "Marque"

strField2 = "Groupe de periode"

On Error Resume Next
Application.EnableEvents = True
Application.ScreenUpdating = True

    If Target.Address = Range("b1").Address Then
        
        For Each ws In ThisWorkbook.Worksheets
            For Each pt In ws.PivotTables
                With pt.PageFields(strField)
                    For Each pi In .PivotItems
                        If pi.Value = Target.Value Then
                            .CurrentPage = Target.Value
                            Exit For
                        Else
                            .CurrentPage = "(All)"
                        End If
                    Next pi
                End With
            Next pt
        Next ws
    
    End If
    
    On Error Resume Next
    
Application.EnableEvents = True
Application.ScreenUpdating = True

    If Target.Address = Range("b2").Address Then
        
        For Each ws In ThisWorkbook.Worksheets
            For Each pt In ws.PivotTables
                With pt.PageFields(strField2)
                    For Each pi In .PivotItems
                        If pi.Value = Target.Value Then
                            .CurrentPage = Target.Value
                            Exit For
                        Else
                            .CurrentPage = "(All)"
                        End If
                    Next pi
                End With
            Next pt
        Next ws
    
    End If
End Sub
b1 et b2 etant des listes de validations.
ce code est OK dans excel 2003, mais pas dans 2007. :confused:
Help!
Merci.
Ingrid.
 

Discussions similaires

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
314 051
Messages
2 105 057
Membres
109 242
dernier inscrit
zaboul2