Remove all Pivot table rows

Molden

Active Member
Joined
Jun 20, 2006
Messages
372
Hi all,

Does anyone know how to unselect the fields in the rows selection in a pivot table.

Ive removed all fields in the pivot table but I would like to keep whats in the value and columns?

Thanks
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,139
The following macro assumes that the active sheet contains the pivottable, and that the pivottable is named "PivotTabe1"...

Code:
Option Explicit

Sub HideRowFields()


    Dim pt As PivotTable
    Dim pf As PivotField
    
    Set pt = ActiveSheet.PivotTables("PivotTable1")
    
    For Each pf In pt.PivotFields
        If pf.Orientation = xlRowField Then
            pf.Orientation = xlHidden
        End If
    Next pf
    
    Set pt = Nothing
    Set pf = Nothing
    
End Sub
Hope this helps!
 

Watch MrExcel Video

Forum statistics

Threads
1,096,027
Messages
5,447,939
Members
405,473
Latest member
faworange

This Week's Hot Topics

Top