vba event pivot table change code example Example: vba refresh pivot table Private Sub Worksheet_Deactivate() ThisWorkbook.RefreshAll End Sub