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
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