Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default PivotTable.Refresh woes

Given that I have a worksheet (ws1) with two PivotTables (pt1, pt2) that rely
on data from three other worksheets (ws2, ws3, ws4) all in the same workbook.

I need to be able to change data in ws2-4 and then have those changes be
reflected in ws1.pt1 and ws1.pt2 .

The best case scenario would be to right-click on a pivot table and then
select the "! Refresh Data" option but for some reason this is greyed-out.
Can someone tell me why this would be greyed-out?


Other option I've tried was to add a button to each of the data worksheets
(ws2--ws4) that would run the following code:

Code:
Private Sub btnUpdate_Click()

   Dim pvtTable As PivotTable

   For Each pvtTable In Worksheets("ws1").PivotTables
       MsgBox pvtTable.Name
       pvtTable.RefreshTable
   Next pvtTable

End Sub
However this results in the following error
Code:
Run-time error '1004':

Refresh has been disabled by a Visual Basic macro.
Can anyone provide any insight?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default PivotTable.Refresh woes

After lots of trial and error, I resolved this.

Turns out both issues were caused by the fact that something somewhere was
setting the PivotCache.EnableRefresh property to False for each PivotTable.
Manually setting this to True in code seems to have solved both issues.

"Jeremy Ragan" wrote:

Given that I have a worksheet (ws1) with two PivotTables (pt1, pt2) that rely
on data from three other worksheets (ws2, ws3, ws4) all in the same workbook.

I need to be able to change data in ws2-4 and then have those changes be
reflected in ws1.pt1 and ws1.pt2 .

The best case scenario would be to right-click on a pivot table and then
select the "! Refresh Data" option but for some reason this is greyed-out.
Can someone tell me why this would be greyed-out?


Other option I've tried was to add a button to each of the data worksheets
(ws2--ws4) that would run the following code:

Code:
 Private Sub btnUpdate_Click()
 
    Dim pvtTable As PivotTable
 
    For Each pvtTable In Worksheets("ws1").PivotTables
        MsgBox pvtTable.Name
        pvtTable.RefreshTable
    Next pvtTable
 
 End Sub
However this results in the following error
Code:
 Run-time error '1004':
 
 Refresh has been disabled by a Visual Basic macro.

Can anyone provide any insight?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA and PivotTable refresh alondon Excel Programming 1 November 21st 06 03:46 AM
PivotTable woes danison Excel Discussion (Misc queries) 4 December 10th 05 01:10 PM
PivotTable After Refresh Event??? Edd Excel Programming 0 October 6th 04 12:42 PM
refresh in pivottable Kanan Excel Programming 3 March 5th 04 01:11 AM
Refresh a PivotTable using VBA (SQL generated Pivot) Paul LaPlant Excel Programming 0 February 6th 04 03:20 PM


All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"