Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro will not fire

Status
Not open for further replies.

jrobin5881

Technical User
Mar 10, 2004
228
US
I constructed a pivot table of the data on sheet 3 in the workbook and then renamed the pivot table worksheet "Rollup". What I'm trying to do is have the pivot table located on "Rollup" refresh automatically if/when I edit sheet 3 where the original information is stored.

But the code I'm using below (which I have attached to sheet 3) will not fire when I change any data?


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
 'If data on this worksheet changes, refresh the pivot table
    Sheets("Rollup").PivotTables("PivotTable1").RefreshTable

End Sub
 






SelectionChange is not Change.

You want Worksheet_Change.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 




I'd suggest, instead to use the WorksheetActivate event.

Why refresh every swingin' time your change something in the source data? Why not when you activate the sheet containing the PT, assuming that it is never active when any of the source data is changed.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
maybe I'm going about it wrong.
I send the workbook out as an email tracking sheet. My intent is to copy and paste the responses into sheet 3 as they're returned to me. So when I do that I want the pivot table on the "Rollup" sheet to refresh to include the new data without me having to pull up the toolbar and click the refresh button.
 




Exactly my thought as well.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top