Auto Update on Event

  • Thread starter Thread starter CarlosAntenna
  • Start date Start date
C

CarlosAntenna

If I understood what I read in other posts in this NG, it is possible to
have certain events trigger an action.

I have a data table on one worksheet and a pivot table based on that data on
another worksheet. How can I cause the pivot table to be updated when I
switch sheets?

--
 
Antenna,

In the sheet module, paste this:

Private Sub Worksheet_Activate()
PivotTables("PivotTable2").PivotCache.Refresh
End Sub

Change the name of the pivot table to match.
 
Paste it where? What is "sheet module"?

--
Earl Kiosterud said:
Antenna,

In the sheet module, paste this:

Private Sub Worksheet_Activate()
PivotTables("PivotTable2").PivotCache.Refresh
End Sub

Change the name of the pivot table to match.

--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

CarlosAntenna said:
If I understood what I read in other posts in this NG, it is possible to
have certain events trigger an action.

I have a data table on one worksheet and a pivot table based on that
data
 
To put a macro into your workbook:

ALT-F11 to the VBE (Visual Basic Environment). "Microsoft Visual Basic" in
the title bar.

If you don't see pane "Project" at the left (it looks like an outline), open
it with View - Project Explorer. It will have boxes for Sheet1, Sheet2,
ThisWorkbook, and possibly Module1, etc.

Locate your workbook (it's a project).

Select the module you want to use (Sheet1, Module1, ThisWorkbook, etc.).
Double-click it, which will open a code window for it at the right. If it's
a regular module you need, but there are none (usually Module1, Module2,
etc) in the Modules section, use Insert - Module.

Type or paste your code into the module.

Alt-Tab back to Excel at any time.

In your case, you want the Sheet tab for the sheet containing the pivot
table, not a regular module.

--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

CarlosAntenna said:
Paste it where? What is "sheet module"?

--
 
Back
Top