Macro required to reverse another macro?

Tarqs

Board Regular
Joined
Feb 14, 2011
Messages
120
Hi All,

I have this macro which disables the filter functions on a pivot table. I now need another macro which will re-instate or reverse this function. Any help greatly appreciated.

code below to disable below

Code:
Sub DisableSelection()
Dim pt As PivotTable
Dim pf As PivotField
Set pt = ActiveSheet.PivotTables(1)  
   For Each pf In pt.PivotFields      
       pf.EnableItemSelection = False  
   Next pf
End Sub


</PRE>
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Here's a toggle:

Code:
Sub ToggleSelection()
    Dim pt As PivotTable
    Dim pf As PivotField
    Set pt = ActiveSheet.PivotTables(1)
    For Each pf In pt.PivotFields
       pf.EnableItemSelection = Not pf.EnableItemSelection
    Next pf
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,910
Messages
5,525,583
Members
409,651
Latest member
Quasar Hunter

This Week's Hot Topics

Top