I would like my pivot table to refresh itself just by clicking on the tab

PETRODATAjames

New Member
Joined
Aug 20, 2022
Messages
21
Office Version
  1. 365
Platform
  1. Windows
I have a workbook with 5 worksheets

1.) Instructions
2.) Instructor Pay Data
3.) Instructor Summary - this is where the two pivot tables reside
4.) Instructor and Location Payrate
5.) Master Pay Rates

Can I have a VBA, that will automatically refresh the Pivot Table, just by clicking on that tab to open the worksheet? This is the worksheet code already on this sheet, just in case you need to know.

Private Sub Worksheet_Activate()
Application.Goto [A1], True

Me.UsedRange.Columns.AutoFit
End Sub


Thanks,
James E.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi, you can try adjusting you Worksheet_Activate() to this:

VBA Code:
Private Sub Worksheet_Activate()
Dim PT As PivotTable
For Each PT In Me.PivotTables
    PT.PivotCache.Refresh
Next PT
Application.Goto [A1], True
Me.UsedRange.Columns.AutoFit
End Sub
 
Upvote 1
Solution

Forum statistics

Threads
1,215,079
Messages
6,123,000
Members
449,092
Latest member
masterms

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