Hello all!
So I've got a VBA code on the worksheet. This basically says to filter the PivotTable based on the value in B2. However, when the value in B2 is blank OR does not match with anything, it will show me everything in the PivotTable.
Is there any way to change this to make it show nothing if the value in B2 doesn't match anything in the filter?
The code I used on the worksheet is the following:
I'm pretty clueless regarding VBA, so the solution might be really simple. Any help would be greatly appreciated!![]()
Private Sub Worksheet_Change(ByVal Target As Range) 'Update by Extendoffice 20180702 Dim xPTable As PivotTable Dim xPFile As PivotField Dim xStr As String On Error Resume Next If Intersect(Target, Range("B2")) Is Nothing Then Exit Sub Application.ScreenUpdating = False Set xPTable = Worksheets("Sheet1").PivotTables("PivotTable1") Set xPFile = xPTable.PivotFields("itemprod") xStr = Target.Text xPFile.ClearAllFilters xPFile.CurrentPage = xStr Application.ScreenUpdating = True End Sub
Bookmarks