This is my closest approach, it is UGLY! but works:
Try with this sample data:
Name Number
lol 2
cheese 2
foo 6
ball 5
lol 5
cheese 3
Make a pivot table using the sample data that will sum the numbers of each "Name"
Lets say you want to filter the "foo" and "lol" values in the pivot field "Name".
Here is the code:
Option Explicit
Sub add_filters_to_pivot()
Dim filters As Variant
Dim pivot_field As PivotItem
Dim pivot_filter As String
Dim element As Variant
Dim filter_exist As Boolean
filters = Array("foo", "lol")
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").ClearAllFilters
For Each pivot_field In ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").PivotItems
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Name")
pivot_filter = pivot_field
filter_exist = filter_array(filters, pivot_filter)
If filter_exist <> True Then
.PivotItems(pivot_filter).Visible = False
End If
End With
Next pivot_field
End Sub
Public Function filter_array(array_to_filter As Variant, filter_string As String) As Boolean
Dim filtered_array As Variant
Dim i As Integer
filtered_array = Filter(array_to_filter, filter_string, True, vbTextCompare)
On Error GoTo is_false
For i = 0 To (UBound(filtered_array) + 1)
If filtered_array(i) = filter_string Then
filter_array = True
Exit Function
End If
Next i
is_false:
filter_array = False
End Function