I have a file that I use to update several pivot tabels.
Some of the pivot tables update based on the code in a Master Pivot table.
6 of the 10 pivot tables update and display correctly using the same code as 4 that update the information in the table but do not display it.
(if I open the pivot table and look at the information for the filter the correct information is there, but the pivot table does not display it)
I tried to refresh all pivot tables after running the update but refreshing does not cause the pivot table to display (tried it manually as well but it didn't update the information that way either).
The only way I can get it to update is to go into the pivot table and look at the label filter, look at the equals value (it has the correct information), then the pivot table updates.
What is needed in the vba code to get it to update this information on its own and why does the code work on 6 out of the 10 pivot tables but not on the others. It is exactly the same code for each one just looking for a different cell in the Top 10 list on the Master Pivot table.
The 4th one doesn't work but the first 3 work with no issues.
Sub Update_Selection()
'
' Update Downtime Report - Update all pivot tables
'
'
Dim Top1 As String
Dim Top2 As String
Dim Top3 As String
Dim Top4 As String
Dim Top5 As String
Dim Top6 As String
Dim Top7 As String
Dim Top8 As String
Dim Top9 As String
Dim Top10 As String
Sheets("DTPivot1").Select
ActiveSheet.PivotTables("DTOverallPivot").PivotFields("Shift").ClearAllFilters
ActiveSheet.PivotTables("DTOverallPivot").PivotFields("Shift").CurrentPage = _
"All"
ActiveSheet.PivotTables("OverallTop10Pivot").PivotFields("Shift").ClearAllFilters
ActiveSheet.PivotTables("OverallTop10Pivot").PivotFields("Shift").CurrentPage = _
"All"
With ActiveSheet.PivotTables("PivotTop1").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H8").Value
End With
With ActiveSheet.PivotTables("PivotTop2").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H9").Value
End With
With ActiveSheet.PivotTables("PivotTop3").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H10").Value
End With
With ActiveSheet.PivotTables("PivotTop4").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H11").Value
End With
Some of the pivot tables update based on the code in a Master Pivot table.
6 of the 10 pivot tables update and display correctly using the same code as 4 that update the information in the table but do not display it.
(if I open the pivot table and look at the information for the filter the correct information is there, but the pivot table does not display it)
I tried to refresh all pivot tables after running the update but refreshing does not cause the pivot table to display (tried it manually as well but it didn't update the information that way either).
The only way I can get it to update is to go into the pivot table and look at the label filter, look at the equals value (it has the correct information), then the pivot table updates.
What is needed in the vba code to get it to update this information on its own and why does the code work on 6 out of the 10 pivot tables but not on the others. It is exactly the same code for each one just looking for a different cell in the Top 10 list on the Master Pivot table.
The 4th one doesn't work but the first 3 work with no issues.
Sub Update_Selection()
'
' Update Downtime Report - Update all pivot tables
'
'
Dim Top1 As String
Dim Top2 As String
Dim Top3 As String
Dim Top4 As String
Dim Top5 As String
Dim Top6 As String
Dim Top7 As String
Dim Top8 As String
Dim Top9 As String
Dim Top10 As String
Sheets("DTPivot1").Select
ActiveSheet.PivotTables("DTOverallPivot").PivotFields("Shift").ClearAllFilters
ActiveSheet.PivotTables("DTOverallPivot").PivotFields("Shift").CurrentPage = _
"All"
ActiveSheet.PivotTables("OverallTop10Pivot").PivotFields("Shift").ClearAllFilters
ActiveSheet.PivotTables("OverallTop10Pivot").PivotFields("Shift").CurrentPage = _
"All"
With ActiveSheet.PivotTables("PivotTop1").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H8").Value
End With
With ActiveSheet.PivotTables("PivotTop2").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H9").Value
End With
With ActiveSheet.PivotTables("PivotTop3").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H10").Value
End With
With ActiveSheet.PivotTables("PivotTop4").PivotFields("alarm_message")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("H11").Value
End With