Kamis, 19 Mei 2011

[ExcelVBA] Refreshing Pivot Tables

 

Hi,
 
I have an Excel file that is retrieving data from an external database and from this data, I have some pivot tables that are slicing up this data.  I have a command button that will refresh the data as well as refresh the pivot tables after the data is refreshed using the following code:
 
Sub Refresh_Data()
Dim pt As PivotTable
ActiveWorkbook.RefreshAll
Sheets("Pivots").Select
      
   For Each pt In ActiveSheet.PivotTables
       pt.RefreshTable
  Next pt

 Worksheets("Summary").Select
 
End Sub
 
The data is refreshing properly, but the pivot tables are not.  Any ideas on how this can be done?  I have two pivot tables on the "Pivots" worksheet that need updating.
 

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar