Is there an "ActiveSheets.RefreshAll" ?

mvatoi

Board Regular
Joined
Jul 21, 2007
Messages
55
Hi all,

I'm trying to create a macro that fresh all the pivot tables within a sheet of a shared workbook.

I do not want to use the Activeworkbook.RefreshAll because I don't want to refresh other people works on a different sheets.

Is there an "ActiveSheets.RefreshAll"?

Right now I have:

ActiveSheet.PivotTables("PivotTable1").RefreshTable
ActiveSheet.PivotTables("PivotTable2").RefreshTable
and so on....

everytime I add/delete a table, I have to go back and change the macro.
I do not have a "Refresh All" Exclamation sign in the Excel, just "Refresh Data" only.

Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
try:
Code:
Sub Test()

Dim pt As PivotTable

    Sheets("Sheet1").Activate
    For Each pt In ActiveSheet.PivotTables
        pt.RefreshTable
    Next pt
    
End Sub
 
Upvote 0
Is it possible to have this without the hardcoded sheet designation and have it refresh all connections instead of just pivottables? I have Power Queries on the sheets that I would also like to refresh upon a cell change. I'm currently using the following but instead of refreshing the whole workbook i just want the queries/connections/pivots on the active sheet to refresh.

Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Me.Range("C4").Address _
Then

ActiveWorkbook.RefreshAll

End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,553
Messages
6,114,279
Members
448,562
Latest member
Flashbond

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