Refresh Pivot Tables

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
764
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

I run a userform that submits data to a database and then comes back to the current workbook and should update the 2 pivot tables I have in my workbook.
The code below refreshes the 1st table but doesn't refresh the 2nd one. I have tried this with and without the second "ActiveWorkbook.Connections("ReportsTabPivot").Refresh" and it doesn't refresh. I have to right click and refresh for this table to update.

Any ideas how I can rectify this to auto refresh like the 1st table?

Code:
'Refreshes data links so pivot tables can update 1st Table
    ActiveWorkbook.Connections("ReportsTabPivot").Refresh
    'refreshes Pivot Table
    Worksheets("Reports").Select
        ThisWorkbook.RefreshAll
'Refreshes data links so pivot tables can update 2nd Table
    Worksheets("Raise").Select
    ActiveWorkbook.Connections("ReportsTabPivot").Refresh
        Range("E24").Select
        ActiveWorkbook.RefreshAll

thanks
Gavin
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi Gavin

I wrote a macro for refreshing all of the pivot tables in all of the sheets of a workbook

VBA Code:
Public Sub PivotRefresh()
'refresh all the pivot tables within a workbook
Dim pt As PivotTable
Dim pc As PivotCache

For Each pc In ActiveWorkbook.PivotCaches
  On Error Resume Next
  pc.Refresh
Next pc

End Sub
 
Upvote 0

Forum statistics

Threads
1,212,938
Messages
6,110,775
Members
448,298
Latest member
carmadgar

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