Link to home
Start Free TrialLog in
Avatar of EnigmaMatter
EnigmaMatterFlag for United States of America

asked on

Prevent Setting .CurrentPage to value that does not exist in PivotField.

Hello,

I have the following VBA to set the .CurrentPage (of the PivotTable Filter "Item Code") to a variable.


Sheets("Purchase Detail").PivotTables("PurchasePT").PivotFields("Item Code").CurrentPage = ItemCodeVariable

Open in new window


If ItemCodeVariable does not equal something that already exists in the the field "Item Code", I want it to fail and return a message. Currently, it will just set the page equal to the variable (effectively doing nothing except being confusing).

For example, "Item Code" would only be loaded with "100", "200","300","400". If I set ItemCodeVariable = 500, it should not work. (In reality, I have thousands of Item Codes).

Any help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EnigmaMatter

ASKER

Rory,

ExcelForum is always the forum I recommend to others for Excel; I have never had a resource help me more in my entire college experience and career. But, I pay $25/Month for Experts Exchange, so I figured I ought to use it.

The one thing that Experts Exchange has is private questions -- makes me feel more comfortable talking because of the very proprietary nature of what I do.

I will try out these solutions!
Thanks!