Macro for Pivot in MS Excel 2003 vs 2007

M

MichaelR

Hi,

I have the following macro that clears all filters in a pivot table of mine
in 2007:

Sheets(2).PivotTables("PivotTable1").ClearAllFilters.

When I try to run the macro in 2003 I get an error message that says:
"Object doesn't support the property or method."

Any ideas for how I can clear all filters in my pivot table in excel 2003
using a macro.

Thanks.
 
D

Debra Dalgleish

'=========================
Sub PivotShowItemResetSort()
'show all items in field
'sort is set to Manual to prevent errors, e.g.
'unable to set Visible Property of PivotItem class
'returns sort order to previous setting
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim intASO As Integer

Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
For Each pt In ActiveSheet.PivotTables
pt.ManualUpdate = True
For Each pf In pt.VisibleFields
intASO = pf.AutoSortOrder
pf.AutoSort xlManual, pf.SourceName
For Each pi In pf.PivotItems
pi.Visible = True
Next pi
pf.AutoSort intASO, pf.SourceName
pf.CurrentPage = "(All)"
Next pf
pt.ManualUpdate = False
Next pt
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
'=========================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top