VBA To remove filters from Pivot tables

Corleone

Well-known Member
Joined
Feb 2, 2003
Messages
752
Office Version
  1. 365
im looking to add in some code to an existing macro at the start which selects any pivot table
in worksheet "pivot tables" and removes any filters on them which exist in the rows/or pages

any help appreciated

cheers
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Corleone

Well-known Member
Joined
Feb 2, 2003
Messages
752
Office Version
  1. 365
Yup! (no need to shout)

The problem i have is, the pivot table has two categories both entitled (all) in the dropdown
and it picks the "(all)" which has no values assigned to it

i ve found another way around it though cheers
 

kavster

New Member
Joined
Apr 3, 2012
Messages
5
Could you please post your solution up here? I'm having a similar issue.

Cheers.
 

Corleone

Well-known Member
Joined
Feb 2, 2003
Messages
752
Office Version
  1. 365
This was a while back now, but i recall that part of the proble was caused by having some records that had been counted in the past by the pivot table under the category of "All"
the,category on these records were subsequently changed to something else to prevent, but the pivot table still made a reference to them.

i the used this macro below to remove any categories in the pivot table which were no longer applicable(including the second "ALL")
------------------------------------------------------------------------------------

Sub pivotDeleteMissingItems()
'prevents unused items in non-OLAP PivotTables
'pivot table tutorial by contextures.com
Dim pt As PivotTable
Dim ws As Worksheet
Dim pc As PivotCache

'change the settinET
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
Next pt
Next ws

'refresh all the pivot caches
For Each pc In ActiveWorkbook.PivotCaches
On Error Resume Next
pc.Refresh
Next pc

End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,026
Messages
5,856,928
Members
431,838
Latest member
mydayisgood

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top