Hello Everybody,
I raised my request on excelforum but there was no response hence I am raising this request in Mr.Excel forum. Below is the link to my post on Excelforum for your reference...
Select Multiple item in Pivot Tables based on a Cell Value
I have below code which selects the item in pivot table based on a cell value and it's working as desired.
But when there are more than the same values in the filter, it does not select all.
e.g.
If the cell value is "LHR" then all items of filters containing "LHR" should get selected. It's like a Search option in the Pivot table, where it allows you to Select All Search Items.
In the below case, LHRBOM & KULLHR should get selected.
NONDIRECTIONAL OD (Filter Name)
LHRBOM
KULLHR
BOMMXP
ZRHCDG
CDGPAR
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xPTable As PivotTable
Dim xPfile As PivotField
Dim xStr As String
On Error Resume Next
If Intersect(Target, Range("B1:B3")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Set xPTable = Worksheets("Sheet9").PivotTables("PivotTable4")
Set xPfile = xPTable.PivotFields("NonDirectional")
xStr = Range("B2")
xPfile.ClearAllFilters
xPfile.CurrentPage = xStr
Application.ScreenUpdating = True
End Sub
Regards,
Shan
I raised my request on excelforum but there was no response hence I am raising this request in Mr.Excel forum. Below is the link to my post on Excelforum for your reference...
Select Multiple item in Pivot Tables based on a Cell Value
I have below code which selects the item in pivot table based on a cell value and it's working as desired.
But when there are more than the same values in the filter, it does not select all.
e.g.
If the cell value is "LHR" then all items of filters containing "LHR" should get selected. It's like a Search option in the Pivot table, where it allows you to Select All Search Items.
In the below case, LHRBOM & KULLHR should get selected.
NONDIRECTIONAL OD (Filter Name)
LHRBOM
KULLHR
BOMMXP
ZRHCDG
CDGPAR
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xPTable As PivotTable
Dim xPfile As PivotField
Dim xStr As String
On Error Resume Next
If Intersect(Target, Range("B1:B3")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Set xPTable = Worksheets("Sheet9").PivotTables("PivotTable4")
Set xPfile = xPTable.PivotFields("NonDirectional")
xStr = Range("B2")
xPfile.ClearAllFilters
xPfile.CurrentPage = xStr
Application.ScreenUpdating = True
End Sub
Regards,
Shan