Changing Criteria In Rerport Filter In Pivot Table In VBA

999HelpPlease

New Member
Joined
Jul 16, 2014
Messages
35
I am trying to create a pivot table with VBA where I can deselect some options in my report filter.

I have been able to create the pivot I just don't know how to deselect.

This is going to be an automated process in the end that creates multiple pivot tables with specific data.

This is what I have so far:


ActiveWorkbook.Sheets("Data").Select
Range("a1").Select
Set objTable = Sheet2.PivotTableWizard

Set objField = objTable.PivotFields("Ship-to (item) Cust Sales Office")
objField.Orientation = xlRowField

Set objField = objTable.PivotFields("Region")
objField.Orientation = xlRowField


Set objField = objTable.PivotFields("Year")
objField.Orientation = xlColumnField


Set objField = objTable.PivotFields("Net Value (Loc Currency)")
objField.Orientation = xlDataField
objField.Function = xlSum
objField.NumberFormat = "$ #,##0"


Set objField = objTable.PivotFields("Header Groups")
objField.Orientation = xlPageField


This is where I have my problem. I want to deselect - SE_03, SE_09, etc
ActiveSheet.PivotTables("PivotTable1").PivotFields("Header Groups").PivotItems ( _
"SE_03")
ActiveSheet.PivotTables("PivotTable1").PivotFields("Header Groups").PivotItems ( _
"SE_09")
ActiveSheet.PivotTables("PivotTable1").PivotFields("Header Groups").PivotItems ( _
"SE_16")
ActiveSheet.PivotTables("PivotTable1").PivotFields("Header Groups").PivotItems ( _
"SE_17")


Set objField = objTable.PivotFields("Otto Bock Strategic Business Segment B")
objField.Orientation = xlPageField

This is where I have my problem. I want to deselect - SE_63, SE_64, etc
ActiveSheet.PivotTables("PivotTable1").PivotFields("Otto Bock Strategic Business Segment B").PivotItems ( _
"SE_63")
ActiveSheet.PivotTables("PivotTable1").PivotFields("Otto Bock Strategic Business Segment B").PivotItems ( _
"SE_64")




End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,236
Messages
6,170,917
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