ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to Refresh Pivot Table (https://www.excelbanter.com/excel-programming/338856-code-refresh-pivot-table.html)

S Jackson

Code to Refresh Pivot Table
 
I have a workbook with multiple worksheets. Each worksheet has its own
pivot table.

I put this code on the first worksheet with a pivot table and it works
great:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.PivotTables(1).PivotCache.Refresh
End Sub
But, when I copy this code to the second worksheet, I get this error:
"Pivot table is not valid."

What's up?
S. Jackson



S Jackson

Code to Refresh Pivot Table
 
Okay, I somehow fixed my problem by simply deleting the pivot table on the
second worksheet and then re-inserting it. Everything works fine now. Go
figure?

S. Jackson

"S Jackson" wrote in message
...
I have a workbook with multiple worksheets. Each worksheet has its own
pivot table.

I put this code on the first worksheet with a pivot table and it works
great:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.PivotTables(1).PivotCache.Refresh
End Sub
But, when I copy this code to the second worksheet, I get this error:
"Pivot table is not valid."

What's up?
S. Jackson






All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com