Dynamic data in PivotSelect statement

M

mikearelli

I have a table that changes daily that I am creating a pivot table from.
One day may show Item1 Item2 and Item3, but the next day the source data may
only include Item2 and Item3 (no Item1)

I would like to assign certain items to a group, but I never know which item
will be in the source data for that day.

ActiveSheet.PivotTables("PivotTable2").PivotSelect _
"Item["'Item1',"'Item2',"'Item3'"] 'ALL ITEMS'", xlDataAndLabel, True
Selection.Group

This statement works great if all 3 items are in the source data for today,
but if Item2 is missing from the source data, I get an error and the group
isn't created.

How can I trap for the error and bypass?
 

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