Bonjour à toutes et à tous,
Dans les paramètres d'un champ d'un TCD je retrouve des éléments qui en on
fait partie mais qui, depuis, n'ont plus raison d'être.
Je peux effectivement les masquer mais comme j'utilise une macro qui compte
les items, celle-ci tient compte des éléments non désirés.
Comment m'y prendre pour rendre une 2ème jeunesse à ce TCD?
Merci
--
René Delcourt
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Sylfanie
Dans les paramètres d'un champ d'un TCD je retrouve des éléments q ui en on fait partie mais qui, depuis, n'ont plus raison d'être.
Bonjour,
Voici le code que j'utilise pour ce problème.
Stéphane.
Sub RemoveOldLabels(oPiv As PivotTable)
'Supprime les labels sans données
Dim oField As PivotField Dim oItem As PivotItem Dim NbPivotItems As Double Dim NbPivotItemsProcessed As Double Dim xlModeDeCalcul As Double
On Error Resume Next xlModeDeCalcul = Application.Calculation Application.Calculation = xlCalculationManual Application.ScreenUpdating = False
For Each oField In oPiv.PivotFields If oField.Name <> "Data" Then NbPivotItems = NbPivotItems + oField.PivotItems.Count End If Next
For Each oField In oPiv.PivotFields If oField.Name <> "Data" Then For Each oItem In oField.PivotItems NbPivotItemsProcessed = NbPivotItemsProcessed + 1 Application.StatusBar = oPiv.Parent.Name & " mise à jour des labels: " & Format(NbPivotItemsProcessed / NbPivotItems, "0.00%") If oItem.RecordCount = 0 And _ Not oItem.IsCalculated Then oItem.Delete End If Next End If Next Application.StatusBar = False Application.Calculation = xlModeDeCalcul
End Sub
Dans les paramètres d'un champ d'un TCD je retrouve des éléments q ui en on
fait partie mais qui, depuis, n'ont plus raison d'être.
Bonjour,
Voici le code que j'utilise pour ce problème.
Stéphane.
Sub RemoveOldLabels(oPiv As PivotTable)
'Supprime les labels sans données
Dim oField As PivotField
Dim oItem As PivotItem
Dim NbPivotItems As Double
Dim NbPivotItemsProcessed As Double
Dim xlModeDeCalcul As Double
On Error Resume Next
xlModeDeCalcul = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
For Each oField In oPiv.PivotFields
If oField.Name <> "Data" Then
NbPivotItems = NbPivotItems + oField.PivotItems.Count
End If
Next
For Each oField In oPiv.PivotFields
If oField.Name <> "Data" Then
For Each oItem In oField.PivotItems
NbPivotItemsProcessed = NbPivotItemsProcessed + 1
Application.StatusBar = oPiv.Parent.Name & " mise à
jour des labels: " & Format(NbPivotItemsProcessed / NbPivotItems,
"0.00%")
If oItem.RecordCount = 0 And _
Not oItem.IsCalculated Then
oItem.Delete
End If
Next
End If
Next
Application.StatusBar = False
Application.Calculation = xlModeDeCalcul
Dans les paramètres d'un champ d'un TCD je retrouve des éléments q ui en on fait partie mais qui, depuis, n'ont plus raison d'être.
Bonjour,
Voici le code que j'utilise pour ce problème.
Stéphane.
Sub RemoveOldLabels(oPiv As PivotTable)
'Supprime les labels sans données
Dim oField As PivotField Dim oItem As PivotItem Dim NbPivotItems As Double Dim NbPivotItemsProcessed As Double Dim xlModeDeCalcul As Double
On Error Resume Next xlModeDeCalcul = Application.Calculation Application.Calculation = xlCalculationManual Application.ScreenUpdating = False
For Each oField In oPiv.PivotFields If oField.Name <> "Data" Then NbPivotItems = NbPivotItems + oField.PivotItems.Count End If Next
For Each oField In oPiv.PivotFields If oField.Name <> "Data" Then For Each oItem In oField.PivotItems NbPivotItemsProcessed = NbPivotItemsProcessed + 1 Application.StatusBar = oPiv.Parent.Name & " mise à jour des labels: " & Format(NbPivotItemsProcessed / NbPivotItems, "0.00%") If oItem.RecordCount = 0 And _ Not oItem.IsCalculated Then oItem.Delete End If Next End If Next Application.StatusBar = False Application.Calculation = xlModeDeCalcul