I'm not sure why you would have to run it twice but perhaps it is due to your
If pi.Name = Range("product1") Or pi.Name = Range("product2") Then
Maybe that line could be split like
If pi.Name = Range("product1") Then
...
ElseIf pi.Name = Range("product2") Then
...
Else
...
End If
The whole thing without a for loop
Sub newproduct()
'
On Error Resume Next
Dim pt As PivotTable
Dim pi As PivotItem
Sheets("pivot").Select
Set pt = ActiveSheet.PivotTables("PivotTable1")
For Each pi In pt.PivotFields("Product").PivotItems
pi.Visible = True
'if the criterias are shown in the range, make pivot item visible
If pi.Name = Range("product1") Then
pi.Visible = True
ElseIf pi.Name = Range("product2") Then
pi.Visible = True
'if item not shown in the range, deselect
Else
pi.Visible = False
End If
Next pi
end sub
I don't know for sure if this will work but give it a test. If it doesn't then go with my last post's code sample.
Bookmarks