MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Refreshing Pivot Table

  Asked By: Glenn    Date: Dec 16    Category: MS Office    Views: 975

I have the spreadhsheet which would retrieve data from MS Accesss through ADO
connection whenever the macro is run. Then, there are some fields that are added
to the excel sheet. I have a pivot table to show the data.
Now, whenever, i populate the data on spreadsheet,and I am trying to refresh
the pivot by using this code,

Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
Next pt

This seems to be not working for me. Also, when I manually refresh the data on
pivot, it throws in the error for pivot table fields not being organized as
Please help as I have never coded the pivot table till now.



1 Answer Found

Answer #1    Answered By: Jermaine Powell     Answered On: Dec 16

Before you worry about the code  working, get the spreadsheet  working.

To make data  into a list you right click in the data area and select "Create
List". If there are blanks in the area this will not work and you will need
to get the data organised as a list.

Then go back and get the pivot  table recalc working

Then try your code again. If you have a problem come back to the list, but
don't say "This seems to be not working  for me" - tell us what happens when
you step through the code using F8. Does the pt not change? Do you get an
error message? Does the spreadsheet disappear in a puff of smoke?

While you are doing this, make sure that the sheet  with the pivot tables is
the Active Sheet while the macro  is running.

Didn't find what you were looking for? Find more on Refreshing Pivot Table Or get search suggestion and latest updates.