View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
S Jackson S Jackson is offline
external usenet poster
 
Posts: 12
Default 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