Using VBA code to update filter on pivot table ... works on some but not others ... what am I missing

wpa101835

New Member
Joined
Nov 3, 2014
Messages
2
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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,216,446
Messages
6,130,699
Members
449,586
Latest member
spg5150

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