Refresh Data on Sheet activation

vavs

Well-known Member
Joined
Jul 2, 2004
Messages
516
I have a worksheet that contains form data and a pivot table. The pivot table is based on another worksheet in the same workbook. When the user goes to the worksheet with the pivot table, they need to refresh the data in order to see the corrections. What I would like to do is to refresh the data whenever the user selects this particular worksheet. I can do a ActiveWorkbook.RefreshAll on Worksheet Change. The only problem with this is that it refreshes everything in the workbook and that is substantial. Is there a way to refresh data automatically when I select a particular worksheet?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Something like this should work:

Code:
Private Sub Worksheet_Activate()
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
End Sub
 
Upvote 0
Thanks for the reply. Here is what I ended up doing and it seems to be working.

On each of the affected worksheets, 3 in all, I put the following code:

/*
Private Sub Worksheet_Activate()

ActiveWorkbook.RefreshAll


End Sub
*/

When the user goes to the sheet, the sheet gets updated.

I also added some code that clears all of the fields on one of the sheets before exit. The client is extremely happy.
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,266
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top