VBA - Pivot Tables - isolating categories

Aclare87

New Member
Joined
Mar 23, 2012
Messages
24
Hey, I'm working on a bunch of pivots using VBA. I need to isolate "Bermuda" in a list of countries and am looking for an easier way to isolate. The list is going to get a lot longer and removing fields individually definitely can't be a solution. Also with Visible=False process, after a bunch of them, I had to end and start the with again to continue. Anyone?? This can't be right. Thanks!

With ActiveSheet.PivotTables("BermudaCanada").PivotFields("Domicile Country")
.PivotItems("Australia").Visible = False
.PivotItems("Austria").Visible = False
.PivotItems("Belgium").Visible = False
.PivotItems("Canada").Visible = False
.PivotItems("Cayman Islands").Visible = False
.PivotItems("France").Visible = False
.PivotItems("Germany").Visible = False
.PivotItems("Hong Kong").Visible = False
.PivotItems("Indonesia").Visible = False
.PivotItems("Ireland").Visible = False
.PivotItems("Italy").Visible = False
.PivotItems("Korea").Visible = False
.PivotItems("Netherlands").Visible = False
.PivotItems("Singapore").Visible = False
End With
With ActiveSheet.PivotTables("BermudaCanada").PivotFields("Domicile Country")
.PivotItems("Switzerland").Visible = False
.PivotItems("UK").Visible = False
.PivotItems("USA").Visible = False
End With
 
As for the calls... I have not yet come to that point while teaching myself VBA coding, however, I suspect I may need to learn that functionality now.

It's not too difficult. Post #4 of this thread shows an example. Just place the function code in the same code module of your workbook.

Good luck and just ask if you get stuck. :)
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Jerry, I don't recall thaning you. your suggestions and help worked and I am happy to say I created two Public functions and used the CALL

Thanks agian sir.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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