Stop searching. Start learning and developing your excel skills.
Macro
VBA
Formula
Function
Shortcut
Tricks

» » VBA to Remove Subtotal from Pivot Table

VBA to Remove Subtotal from Pivot Table

December 19, 2019 |
The code below remove/ disable/ do not show subtotal of each row labels. At the same, it repeats each row labels. It can be used as a QAT (Quick Access Toolbar) or can be called in module when you put the codes/ function in the top or above of your macro codes.

Sub PvtNoSubTtl()
         
            Dim pt As PivotTable
            Dim pf As PivotField
            On Error Resume Next
         
            For Each pt In ActiveSheet.PivotTables
                pt.RowAxisLayout xlTabularRow
             
            Next pt
         
            For Each pt In ActiveSheet.PivotTables
                For Each pf In pt.PivotFields
                    pf.RepeatLabels = True
                    pf.Subtotals(1) = True
                    pf.Subtotals(1) = False
                Next pf
            Next pt

End Sub

No comments:

Post a Comment