Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add fields to pivot table
Is there a way to limit the fields that are used in a
pivot table when adding with a VB procedure? For example, I have a list of codes ranging from 1000 to 9000 that will be used as the data source for a pivot table. However, when I run code to add the pivot table, I want only codes ranging between 7000 and 8999 to be in the pivot table. Right now after adding the pivot I have to go through and manually deselect all the codes I don't want, but this is a great many codes. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add fields to pivot table
Turn on the macro recorder, deselect a few of the codes you don't want, then
turn off the macro recorder. You should get code that looks similar to the following. Replace the ".PivotItems("Item1").Visible = False" lines with a For loop or something. This code assumes that PivotFields("FieldName") is a row field, not a page field. With ActiveSheet.PivotTables("PivotTable1").PivotFields ("FieldName") .PivotItems("Item1").Visible = False .PivotItems("Item2").Visible = False .PivotItems("Item3").Visible = False End With -- Regards, Bill "Lee" wrote in message ... Is there a way to limit the fields that are used in a pivot table when adding with a VB procedure? For example, I have a list of codes ranging from 1000 to 9000 that will be used as the data source for a pivot table. However, when I run code to add the pivot table, I want only codes ranging between 7000 and 8999 to be in the pivot table. Right now after adding the pivot I have to go through and manually deselect all the codes I don't want, but this is a great many codes. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem inserting calculated pivot fields into Pivot Table (2007) | Excel Discussion (Misc queries) | |||
fields names do not show in excel 2007 pivot table fields list | New Users to Excel | |||
Pivot table fields | Excel Discussion (Misc queries) | |||
number of fields in the row fields in pivot table | Excel Discussion (Misc queries) | |||
Pivot Table Fields | Excel Worksheet Functions |