Force All Pivot Field Items Selected Excel 2003

rickincanada

Board Regular
Joined
Aug 31, 2010
Messages
61
I have a pivot table which I want to force the all of the pivot table items to be selected for a particular pivot table field. One would think that this would be as easy as unlocking all cells on the sheet with the exception of this pivot field and then locking the worksheet. This doesn't work though as I am generating multiple pivot tables on the same workbook for the same range and I get this message: "this command cannot be performed while a protected sheet contains another PivotTable report based on the same data source...".

My thinking is that I can do something along the lines of this:

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim oPI As PivotItem

Application.ScreenUpdating = False

If Target.PivotFields("Item Sold").PivotItems.Count <> Target.PivotFields("Item Sold").VisibleItems.Count Then
For Each oPI In ActiveSheet.PivotTables("PivotTable1").PivotFields("Item Sold").PivotItems
oPI.Visible = True
Next oPI
End If

Application.ScreenUpdating = True
End Sub

This is failing right away though on the If Target.Pivot.... line. Any help you can offer would be great!!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You'll need to have your code do this sequence of steps:

1. Unprotect the Sheet
2. For each PivotTable, make all PivotItems Visible in the "Items Sold" PivotField
3. Protect the Sheet

You'll probably have better results putting this in a macro that you could call with a button instead of trying to use the Worksheet_PivotTableUpdate Event to trigger those 3 steps.

Is your "Items Sold" field a Report Filter(PageField), or a Row Label field?
 
Upvote 0

Forum statistics

Threads
1,203,388
Messages
6,055,129
Members
444,763
Latest member
Jaapaap

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top