huiyin9218
Board Regular
- Joined
- Aug 7, 2018
- Messages
- 53
Hi,
How do I write a code for pivot filter to unselect all and only select "AB1" and "CD*".
I tried to edit from the code that I recorded but it failed and I'm not sure if i'm suppose to use "If Not". Is there any other better way?
I'm still a beginner in vba, hope you guys can help me
How do I write a code for pivot filter to unselect all and only select "AB1" and "CD*".
I tried to edit from the code that I recorded but it failed and I'm not sure if i'm suppose to use "If Not". Is there any other better way?
I'm still a beginner in vba, hope you guys can help me
Code:
Sub Macro1()
ActiveSheet.PivotTables("PivotTable3").PivotFields("Process Type").CurrentPage _
= "(All)"
With ActiveSheet.PivotTables("PivotTable3")
ActiveSheet.PivotTables("PivotTable3").PivotFields("Process Type"). _
EnableMultiplePageItems = True
For Each PivotItem In .PivotFields("Process Type").PivotItems
PivotItem.Visible = True
Next PivotItem
For Each PivotItem In .PivotFields("Process Type").PivotItems
If Not PivotItem.Name = "*" & Range("Process Type").Value & "*" Then PivotItem.Visible = False
Next PivotItem
End With
End Sub
Last edited: