Djblois
06-20-2007, 11:21 AM
I am having 2 problems with code on a PivotTable. If I Record New Macro this is what I get:
ActiveSheet.PivotTables("PivotTable1").PivotFields("Cust#").CurrentPage = _
"(All)"
I changed that into this:
On Error Resume Next
pvtTable.PivotFields("Customer#").CurrentPage = _
"(All)"
neither one works when I run the code. Also I created this to unhide items in a Pivot Table:
Sub ShowPivotField(ByVal pvtField As String)
Dim pvtItem As PivotItem
For Each pvtItem In pvtTable.PivotFields(pvtField).PivotItems
pvtItem.Visible = True
Next
Set pvtItem = Nothing
End Sub
ShowPivotField "Product"
ShowPivotField "Code"
ShowPivotField "Delivered Price"
ShowPivotField "Pick-Up Allowance/Case"
ShowPivotField "FOB Price"
ShowPivotField "Minimum Delivery"
ShowPivotField "Begin Contract"
ShowPivotField "End Contract"
ShowPivotField "Whse"
ShowPivotField "Chain"
ShowPivotField "Brand"
ShowPivotField "Contact"
ShowPivotField "SlsPersn"
ShowPivotField "Cust"
They all work up to ShowPivotField "Minimum Delivery", which I checked ten times the name is exactly the same. Here is a sample workbook to test for both problems.
ActiveSheet.PivotTables("PivotTable1").PivotFields("Cust#").CurrentPage = _
"(All)"
I changed that into this:
On Error Resume Next
pvtTable.PivotFields("Customer#").CurrentPage = _
"(All)"
neither one works when I run the code. Also I created this to unhide items in a Pivot Table:
Sub ShowPivotField(ByVal pvtField As String)
Dim pvtItem As PivotItem
For Each pvtItem In pvtTable.PivotFields(pvtField).PivotItems
pvtItem.Visible = True
Next
Set pvtItem = Nothing
End Sub
ShowPivotField "Product"
ShowPivotField "Code"
ShowPivotField "Delivered Price"
ShowPivotField "Pick-Up Allowance/Case"
ShowPivotField "FOB Price"
ShowPivotField "Minimum Delivery"
ShowPivotField "Begin Contract"
ShowPivotField "End Contract"
ShowPivotField "Whse"
ShowPivotField "Chain"
ShowPivotField "Brand"
ShowPivotField "Contact"
ShowPivotField "SlsPersn"
ShowPivotField "Cust"
They all work up to ShowPivotField "Minimum Delivery", which I checked ten times the name is exactly the same. Here is a sample workbook to test for both problems.