Phelony
04-30-2010, 03:58 AM
Hi guys
I've written the below to open a workbook and refresh the pivot tables in the workbook.
This used to work, however, it's randomly stopped working and after a mornings investigation I'm at a loss as to why. Nothing has changed in either the code or the workbook, but clearly something is wrong. :dunno
All it does now is open the workbook, recalculate the cells, save it and close it. It completely ignores the pivot refresh coding?!
Sub AllWorksheetPivots()
'opening workbook
Workbooks.Open Filename:="x:\quarter 2.xls"
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.RefreshTable
Next pt
'Call pivotrefresh
Next ws
'save and close
Workbooks("quarter 2.xls").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
Any ideas?
Phel :thumb
I've written the below to open a workbook and refresh the pivot tables in the workbook.
This used to work, however, it's randomly stopped working and after a mornings investigation I'm at a loss as to why. Nothing has changed in either the code or the workbook, but clearly something is wrong. :dunno
All it does now is open the workbook, recalculate the cells, save it and close it. It completely ignores the pivot refresh coding?!
Sub AllWorksheetPivots()
'opening workbook
Workbooks.Open Filename:="x:\quarter 2.xls"
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.RefreshTable
Next pt
'Call pivotrefresh
Next ws
'save and close
Workbooks("quarter 2.xls").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
Any ideas?
Phel :thumb