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

Similar Threads

Sum Values from different column 1
Combobox with a dynamic list 12
Pivot: grand totals 4
Help needed in Excel macro 1
Excel Excel macro Help!! 0
Alternative to pivot table ? 8
PivotSelect 1
Algorithm for multi combination 10

Top