Guinaba
Board Regular
- Joined
- Sep 19, 2018
- Messages
- 218
- Office Version
- 2016
- Platform
- Windows
Hi guys,
I am using the code below to refresh a pivot table, which is in another worksheet but in the same workbook, not sure what I am missing because it only works if I run it within Sales worksheet. I thought that using the whole object's hierarchy that would work.
I am using the code below to refresh a pivot table, which is in another worksheet but in the same workbook, not sure what I am missing because it only works if I run it within Sales worksheet. I thought that using the whole object's hierarchy that would work.
VBA Code:
Sub RefreshSales()
ActiveWorkbook.Sheets("Sales").PivotTables(1).PivotCache.Refresh
ActiveWorkbook.Sheets("Sales").PivotTables(1).RefreshTable
MsgBox "Refresh completed", vbInformation
End Sub