Automatic refresh of pivot tables

G

Guest

I am looking for an automatic procedure to open a file (excel 2003), refresh
all pivot tables (olap cubes) and save it.
thanks
 
G

Guest

Hi

Sub OpenUpdatePivotTablesSave()

Dim pt As PivotTable
Dim ws As Worksheet
Dim wb As Workbook

Set wb = Workbooks.Open("C:\Myfile.xls")

For Each ws In wb.Worksheets

For Each pt In ws.PivotTables
pt.RefreshTable
Next pt

Next ws

wb.Save

End Sub
 
G

Guest

Thanks Wigi. it works


Wigi said:
Hi

Sub OpenUpdatePivotTablesSave()

Dim pt As PivotTable
Dim ws As Worksheet
Dim wb As Workbook

Set wb = Workbooks.Open("C:\Myfile.xls")

For Each ws In wb.Worksheets

For Each pt In ws.PivotTables
pt.RefreshTable
Next pt

Next ws

wb.Save

End Sub
 

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