Sub pivot_table_select()
Dim input1 As String
Dim input2 As String
Dim field1 As String
Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim store_array(0 To 1) As String
Dim inp_array() As String
Dim i, j As Integer
Dim pf_counter As Integer
Dim v_counter As Integer
For i = LBound(store_array) To UBound(store_array)
store_array(i) = ""
Next i
Set ws = ThisWorkbook.ActiveSheet
If ws.PivotTables.Count > 0 Then
Set pt = ws.PivotTables(1)
Else
MsgBox ("No pivot table")
Exit Sub
End If
field1 = "Item Title"
Set pf = pt.PivotFields(field1)
inp = InputBox("Please enter")
If InStr(1, inp, " ", vbTextCompare) > 0 Then
ReDim inp_array(0 To InStr(1, inp, " ", vbTextCompare))
inp_array = Split(inp, " ")
Else
ReDim inp_array(0 To 0)
inp_array(0) = inp
End If
inp_count = 0
For i = LBound(inp_array) To UBound(inp_array)
store_array(i) = inp_array(i)
inp_count = inp_count + 1
Debug.Print inp_count
Next i
pf_count = 1
For Each pi In pf.PivotItems
pf_count = pf_count + 1
For j = 0 To inp_count - 1
If InStr(1, pi.Name, store_array(j), vbTextCompare) = 0 Then
pi.Visible = False
Exit For
End If
Next j
If pf_count Mod 100 = 0 Then
ActiveSheet.Cells(Int(pf_count / 100), 7) = pf_count
End If
Next pi
End Sub