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
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.