Macro for auto refresh

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

Is there a macro where I change a cell in one sheet and the pivot table will
auto refresh.

If I change the cell B18 in Dashboard sheet, the pivot table in City sheet
will refresh automatically.

Thanks.
 
Right click on Dashboard sheet tab, view code, paste this in:

'=====
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B18")) Is Nothing Or _
Target.Count > 1 Then Exit Sub
'Refreshes all PivotTables in workbook
ThisWorkbook.RefreshAll
End Sub
'======

Note that this requires you the user to change cell B18. The event will not
be triggered if B18 contains a formula whose result changes.
 
Back
Top