Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lee Lee is offline
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem inserting calculated pivot fields into Pivot Table (2007) wamiller36 Excel Discussion (Misc queries) 1 March 5th 10 11:40 PM
fields names do not show in excel 2007 pivot table fields list marlo17 New Users to Excel 2 December 1st 08 01:25 PM
Pivot table fields jodieg Excel Discussion (Misc queries) 2 March 30th 07 02:32 PM
number of fields in the row fields in pivot table UT Excel Discussion (Misc queries) 0 April 13th 06 01:17 AM
Pivot Table Fields smck Excel Worksheet Functions 2 October 27th 05 03:39 AM


All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"