Davisron867
asked on
"With Events" class to capture "After Pivot Table Refresh" event
Experts, Masters and Sages: Is there a way to create an After Pivot Table Refresh event (not Query Refresh) to fire additional code afterwards?
I have multiple users working in local Read Only copies of an Excel file with Pivot Tables sourcing an Access table. Users refresh their Pivot Tables using the Excel Menu or Context Menu.
After the Pivot refresh, I'll fire additional code to update a "Last Refresh Timestamp" that I compare to the "Data Source Timestamp". When Data Source is updated, the Data Source Timestamp > Last Refresh Timestamp and causes formula "=If(Last refresh > Data Source, "", "Update Available")" to display "Update Available".
When users subsequently Refresh, I want the code to update the last refresh Timestamp and the formula then returns a 0-length string and the notification goes away.
I did ask the question recently but accepted an incorrect answer, ID: 26237589
I have multiple users working in local Read Only copies of an Excel file with Pivot Tables sourcing an Access table. Users refresh their Pivot Tables using the Excel Menu or Context Menu.
After the Pivot refresh, I'll fire additional code to update a "Last Refresh Timestamp" that I compare to the "Data Source Timestamp". When Data Source is updated, the Data Source Timestamp > Last Refresh Timestamp and causes formula "=If(Last refresh > Data Source, "", "Update Available")" to display "Update Available".
When users subsequently Refresh, I want the code to update the last refresh Timestamp and the formula then returns a 0-length string and the notification goes away.
I did ask the question recently but accepted an incorrect answer, ID: 26237589
Hello Davisron867,
Each worksheet has a PivotTableUpdate event, and there is a workbook-level SheetPivotTableUpdate event.
Regards,
Patrick
Each worksheet has a PivotTableUpdate event, and there is a workbook-level SheetPivotTableUpdate event.
Regards,
Patrick
ASKER
For the SheetPivotTableUpdate event to work, it appears you need to EnableEvents.
Private Sub Workbook_Open()
Application.EnableEvents = True
End Sub
And then the following executes once for each pivot table in the workbook.
Private Sub Workbook_SheetPivotTableUp date(ByVal Sh As Object, ByVal Target As PivotTable)
With Sheet6.Range("B7")
.FormulaR1C1 = "=[MGMTREP_LEDGER_BAL.xlsm ]Parameter s!R7C2"
.NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"
End With
Sheet6.Cells(7, 3) = Now()
End Sub
Private Sub Workbook_Open()
Application.EnableEvents = True
End Sub
And then the following executes once for each pivot table in the workbook.
Private Sub Workbook_SheetPivotTableUp
With Sheet6.Range("B7")
.FormulaR1C1 = "=[MGMTREP_LEDGER_BAL.xlsm
.NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"
End With
Sheet6.Cells(7, 3) = Now()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
negative...I have 5 pivot tables and it runs 5 times in succession, moving from one to the next as if in a loop.
Davisron867,
If your PTs are based off of other PTs, when the "parent" updates so will the children.
Also, if your PTs are set to refresh on open, when you open the file, they will refresh.
Do you have other code that is forcing refreshes?
Patrick
If your PTs are based off of other PTs, when the "parent" updates so will the children.
Also, if your PTs are set to refresh on open, when you open the file, they will refresh.
Do you have other code that is forcing refreshes?
Patrick
ASKER
In fact I was turning off events somewhere.
Steve