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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,305
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,109,050
Messages
5,526,494
Members
409,704
Latest member
saialkesh

This Week's Hot Topics

Top