Hi have code that runs pivot tables for a variable set of data. the problem i'm running into is that some of the fields I want to filter by won't show up until the data is more mature. Is there a way to look at the data field and set the filters based on the data that is present? So below is the code i'm using. At the beginning of the year, only "Active" will shown up and the code will error out because the other values don't exist. However as the year goes on these values will appear. I'm trying to automate the process so i don't have to go in and add the code as they show up. Thanks!
pvt.PivotFields("Status").PivotItems("Active").Visible = True
pvt.PivotFields("Status").PivotItems("Limited Stock").Visible = False
pvt.PivotFields("Status").PivotItems("Stock Coming").Visible = False
pvt.PivotFields("Status").PivotItems("Pending Stock").Visible = False
pvt.PivotFields("Status").PivotItems("Sold Out").Visible = False
pvt.PivotFields("Status").PivotItems("Active").Visible = True
pvt.PivotFields("Status").PivotItems("Limited Stock").Visible = False
pvt.PivotFields("Status").PivotItems("Stock Coming").Visible = False
pvt.PivotFields("Status").PivotItems("Pending Stock").Visible = False
pvt.PivotFields("Status").PivotItems("Sold Out").Visible = False