VBA To remove filters from Pivot tables

Corleone

Well-known Member
Joined
Feb 2, 2003
Messages
836
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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

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
Back
Top