Commend button to select different pivotitems

shadyshawn

New Member
Joined
Dec 28, 2010
Messages
46
Hi guys. Not sure if anyone had the same issue before, but what I have is a pivot table and then I created few commend buttons so I can select different pivot items from the page field, instead of manually changing the field list each time. But I keep running into a weird issue:

say my button A has the following:
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Service")
.PivotItems("1").Visible = True
.PivotItems("2").Visible = False
.PivotItems("3").Visible = False

And my button B has: the code:
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Service")
.PivotItems("1").Visible = False
.PivotItems("2").Visible = False
.PivotItems("3").Visible = True

When I click on button A, the table is filtered properly showing only item "1", but then when click on button B after that, both item "1" and "3" are selected. What's even more puzzling is that after I click on button B again, it will then de-select "1" and select item "3" only. Any idea on why this might be happening?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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