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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Private Sub Bouton_Valider_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Ctrl As Control
Dim TableApplications() As String
Dim i As Integer
i = 0
Dim PI As Object
Dim oTCD As PivotTable
Dim oTCD_Appli As PivotField
Dim Ligne As Long
Dim Plage As Range
Dim Criteres As Range
Set oTCD = Worksheets("TestAp").PivotTables("Tableau croisé dynamique1")
Set oTCD_Appli = oTCD.PivotFields("AP")
Dim DateStart
'On stocke dans un dico les champs choisis dans la fenêtre (checkbox = true) :
With Sheets("OrgaAp")
.[G2:M65536].ClearContents
Ligne = 1
Set monDicoAppli = CreateObject("Scripting.Dictionary")
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.Checkbox Then
If Ctrl.Value = True Then
monDicoAppli.Add Ctrl.Name, Ctrl.Name
Ligne = Ligne + 1
.Cells(Ligne, 13) = "=""=" & Ctrl.Name & """"
End If
End If
Next Ctrl
Unload Me
Set Criteres = .Range(.[M1], .Cells(.Rows.Count, 13).End(xlUp))
.Range(.[A1], .Cells(.Rows.Count, 5).End(xlUp)).AdvancedFilter xlFilterCopy, Criteres, .[G1:K1]
Set Plage = .Range(.[G1], .Cells(.Rows.Count, 11).End(xlUp))
End With
With Sheets("TestAp")
.PivotTables("Tableau croisé dynamique1").SourceData = "OrgaAp!" & Plage.Address(1, 1, xlR1C1)
End With
'pour calculer le temps d'éxcécution ...
Application.EnableEvents = True
Application.ScreenUpdating = True
monDicoAppli.RemoveAll
End Sub |
Partager