ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro for Pivot in MS Excel 2003 vs 2007 (https://www.excelbanter.com/excel-discussion-misc-queries/196174-macro-pivot-ms-excel-2003-vs-2007-a.html)

MichaelR

Macro for Pivot in MS Excel 2003 vs 2007
 
Hi,

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

Sheets(2).PivotTables("PivotTable1").ClearAllFilte rs.

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.

Debra Dalgleish

Macro for Pivot in MS Excel 2003 vs 2007
 
'=========================
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
'=========================

MichaelR wrote:
Hi,

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

Sheets(2).PivotTables("PivotTable1").ClearAllFilte rs.

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.



--
Debra Dalgleish
Contextures
www.contextures.com/tiptech.html
Blog: http://blog.contextures.com



All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com