Change Pivot Table Field based on a list.

culcuhain

New Member
Joined
Apr 28, 2010
Messages
21
Good morning,
I have my VB where the pivot table page filter is changed based on a list.
Using a For Next loop I have it run through the list and update the pivot table and save it, then go to the next item in the list. The problem I have is not all items in the list are in the pivot table and what happens is that the field I am telling it change to, overwrites the next one. For example, I have group called AAA and BBB. If AAA is not in the pivot table, it will change the name BBB to AAA and pull in BBB data. I want it to error out or something and not overwrite that field.
Here is my code.

Code:
 ActiveSheet.PivotTables("PivotTable4").PivotFields("Providerdept").CurrentPage _
        = Range("A1").Value
    Cells.Select

The cell A1 is the value of the Item in the For Next loop. I want it so if it doesn't find the AAA in the pivot to do another action. I have the code for the other action. Thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top