Hi, I have few pivots table in my VBA, and it's all connect to same data source "CompileData", the pivot table should extend the range of data when weekly I added new lines. But no matter what types of code I put in, it seems like not working at all. I do not know what is the issue, I had tried few codes below and as attached.
I had set the auto refresh in pivot table options, but it will shows run time error if I put this code in private sub.
I had set the auto refresh in pivot table options, but it will shows run time error if I put this code in private sub.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ThisWorkbook.RefreshAll
End Sub
VBA Code:
Sub RefreshAllPivots()
Dim PC As PivotCache
Workbooks("Hotayi RMA Dashboard.xlsm").Activate
For Each PC In ActiveWorkbook.PivotCaches
PC.Refresh
Next PC
End Sub
VBA Code:
Sub RefreshPT()
Application.ScreenUpdating = False
Dim WS As Worksheet
Dim pt As PivotTable
Workbooks("Hotayi RMA Dashboard.xlsm").Activate
For Each WS In Worksheets 'Goes through each WS
For Each pt In WS.PivotTables 'Goes through each PT in WS
pt.RefreshTable
Next pt
Next WS
Application.ScreenUpdating = True
End Sub