Appliquer une maco a plusieurs feuilles contenant un TCD

lionel.layerle

XLDnaute Nouveau
Bonjour

J ai un document excel avec plusieurs feuilles (environ 80).
50 d entres elles ont des TCD.

Je souhaite appliquer cette macro depuis une feuille d administration ne contenant pas de TCD et je souhaite que la macro s applique a toutes les feuilles ayant un TCD. Comment dois je modifier ma macro?

Sub RestrictPivotTable()
Dim pf As PivotField
With ActiveSheet.PivotTables(1)
.EnableWizard = False
.EnableDrilldown = False
.EnableFieldList = False
.EnableFieldDialog = False
.PivotCache.EnableRefresh = False
For Each pf In .PageFields
With pf
.DragToPage = False
.DragToRow = False
.DragToColumn = False
.DragToData = False
.DragToHide = False
End With
Next pf
End With
End Sub

Merci de votre aide

Lionel
 

Pierrot93

XLDnaute Barbatruc
Re : Appliquer une maco a plusieurs feuilles contenant un TCD

Bonjour,

essaye peut être ainsi, non testé... pas de fichier..
Code:
Option Explicit
Sub test()
Dim ws As Worksheet, pt As PivotTable, pf As PivotField
For Each ws In Worksheets
    With ws
        If .PivotTables.Count > 0 Then
            For Each pt In .PivotTables
                With pt
                    .EnableWizard = False
                    .EnableDrilldown = False
                    .EnableFieldList = False
                    .EnableFieldDialog = False
                    .PivotCache.EnableRefresh = False
                    For Each pf In .PageFields
                        With pf
                            .DragToPage = False
                            .DragToRow = False
                            .DragToColumn = False
                            .DragToData = False
                            .DragToHide = False
                        End With
                    Next pf
                End With
            Next pt
        End If
    End With
Next ws
End Sub

bon après midi
@+

Edition : bonjour Hasco:)
 
Dernière édition:
G

Guest

Guest
Re : Appliquer une maco a plusieurs feuilles contenant un TCD

Bonjour,

A tester:
Code:
Sub RestrictPivotTable()
Dim pf As PivotField
Dim sh As Worksheet
    For Each sh In ThisWorkbook.Worksheets
        If sh.PivotTables.Count > 0 Then
            With ActiveSheet.PivotTables(1)
                .EnableWizard = False
                .EnableDrilldown = False
                .EnableFieldList = False
                .EnableFieldDialog = False
                .PivotCache.EnableRefresh = False
            
                For Each pf In .PageFields
                        pf.DragToPage = False
                        pf.DragToRow = False
                        pf.DragToColumn = False
                        pf.DragToData = False
                        pf.DragToHide = False
                Next pf
            End With
        End If
    Next
End Sub

A+
P.S. la prochaine fois utilise l'éditeur avancé des post et la balise
Code:
 (bouton: #) pour éditer tes codes.

[Edition] Hello Pierrot:)
 

Statistiques des forums

Discussions
312 488
Messages
2 088 861
Membres
103 979
dernier inscrit
imed