#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PivotSelect

I have a excel spreadsheet creating a pivot table. In my code I am trying to
select certain states to group, would anyone know how to write the code to
select the states other than those I ask it not to select. For example: I
have states TX, OK, AZ, CO, NV, CA, OR, TN, IN, etc. I want the "pivotselect"
to select all states except "TX, OK, CO, NV", now these 4 states will always
be excluded. As far as the rest of the states, there could be other states
coming in on different days.

Code Example: ActiveSheet.PivotTables("PivotTable2").PivotSelect
"STATE2['Not Like'AZ,CO,NV,OK,TX]", xlDataAndLabel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default PivotSelect

Can you add a field to the source data, indicating whether or not to
include the state? Then use that field in the pivot table to create the
groups.

For example, with a list of excluded states named ExcludeList, use the
following formula in the source data, where State is in column C:

=IF(COUNTIF(ExcludeList,C2),C2,"States")

MCyn wrote:
I have a excel spreadsheet creating a pivot table. In my code I am trying to
select certain states to group, would anyone know how to write the code to
select the states other than those I ask it not to select. For example: I
have states TX, OK, AZ, CO, NV, CA, OR, TN, IN, etc. I want the "pivotselect"
to select all states except "TX, OK, CO, NV", now these 4 states will always
be excluded. As far as the rest of the states, there could be other states
coming in on different days.

Code Example: ActiveSheet.PivotTables("PivotTable2").PivotSelect
"STATE2['Not Like'AZ,CO,NV,OK,TX]", xlDataAndLabel



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
Pivottable Pivotselect string mo_in_france Excel Programming 2 April 15th 05 09:25 AM


All times are GMT +1. The time now is 03:18 PM.

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"