Resetting PivotFields

B

Bony Pony

Hi yet again,
I am trying to run a macro that resets filters to single item selection with
All as the default.

Sub s_reset_chart()
'This Macro removes blank fields from the Pivot and resets the filters to
Default

Application.ScreenUpdating = False
Application.StatusBar = "Resettimg Pivot Filters to Default."
On Error GoTo 0
Set pt = Sheets(s_analysis).PivotTables("s_Data_Pivot")

For Each vmycell In [s_graph_pages] ' Range that contains the Page Field
names in the If vmycell.Value = "" Or vmycell.Value = 0 Then Exit For
Set pf = pt.PivotFields(vmycell.Value)
pf.AutoSort xlManual, vmycell.Value
If vmycell.Value = [ay3].Value Then ' look for value and set default
With pt.PivotFields(vmycell.Value)
.CurrentPage = ("Input Raw Cost - Core")
.EnableMultiplePageItems = False
End With
Else
With pt.PivotFields(vmycell.Value)
.CurrentPage = "(All)"
.EnableMultiplePageItems = False
End With
End If

pf.AutoSort xlAscending, vmycell.Value
Next vmycell

Application.StatusBar = "Filter Reset complete."
Application.ScreenUpdating = True
Application.StatusBar = False

End Sub


Maybe I should become a carpenter instead ..

Any help appreciated.

Best regards,
Bony
 

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