Refreshing Pivot table

J

Joe

Hi All.

I have a workbook with 6 sheets. Each sheet has a pivot table.

I have a button on another form that runs a query and populates yet another
sheet that each pivot table pulls from.

I want the pivot tables to refresh after the query is run.

I loop through all the sheets and then loop through all pivot tables and
call RefreshTable on each. I've also tried Refresh.

What happens is that first 2 sheets seems to refresh but the others don't.
Also, if there are no records when the pivot tables refresh they reduce down
to just the rows and column (which is normal) but when I refresh again and
there are records, the filter I put on the page field isn't retained - this
may be normal. If I reapply the filter I get a message that it cannot
overlap an existing pivot table. There are a few cells in the area that used
to be populated by a pivot table but no longer have any values there. I have
to delete the rows and then apply the filter.

I hope this makes sense.

I wonder if I'm better off creating the pivot tables each time. Are there
any examples of doing this in VBA?

Thanks,
Joe
 
J

joel

Post your code. If two fo the worksheets are updated then it weem tha
the focus may be changing. I think you may be using Active Shee
instead of specifying the sheet by names like Sheets("Sheet1").

What happens if you change the the two query table that get updated t
two different query table doess the same thing happen?

Do you have any Event Macro that may be causing the focus to change t
a different sheet? Event macros could be causing some unexpecte
results
 

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