VBA To remove filters from Pivot tables

Corleone

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

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Corleone

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

Watch MrExcel Video

Forum statistics

Threads
1,109,047
Messages
5,526,464
Members
409,701
Latest member
nitmani

This Week's Hot Topics

Top