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
b1 et b2 etant des listes de validations.
ce code est OK dans excel 2003, mais pas dans 2007.
Help!
Merci.
Ingrid.
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
ce code est OK dans excel 2003, mais pas dans 2007.
Help!
Merci.
Ingrid.