PivotSelect

M

MCyn

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
 
D

Debra Dalgleish

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top