Hello:
Here is my problem: I have a pivot table that I want to be able to search for a specific value. The problem is my code takes a long time. Is there any way this can be coded so that it run faster. Here is the code that I have:
Sub UniqueItem()
'This routine, uniqueItem, selects the name supplied by the user and display it in the PivotTable
'y is the name that we want to display in the pivot table.
Y = InputBox("Please enter the name you would like to filter"
ActiveSheet.PivotTables("PivotTable7"
.ManualUpdate = True
On Error Resume Next
For Each X In ActiveSheet.PivotTables("PivotTable7"
.PivotFields("Rep"
.PivotItems
X.Visible = False
'x.name is our items collection
'If our collection item is equal to y and "No Rep Info",
'then we want to dispaly them in the pivottable
If X.Name = "No Rep Info" Then X.Visible = True
If X.Name = Y Then X.Visible = True
'This is just to show what item the code is on during the loop.
MsgBox X.Name
Next X
End Sub
thanks in advance
Here is my problem: I have a pivot table that I want to be able to search for a specific value. The problem is my code takes a long time. Is there any way this can be coded so that it run faster. Here is the code that I have:
Sub UniqueItem()
'This routine, uniqueItem, selects the name supplied by the user and display it in the PivotTable
'y is the name that we want to display in the pivot table.
Y = InputBox("Please enter the name you would like to filter"
ActiveSheet.PivotTables("PivotTable7"
On Error Resume Next
For Each X In ActiveSheet.PivotTables("PivotTable7"
X.Visible = False
'x.name is our items collection
'If our collection item is equal to y and "No Rep Info",
'then we want to dispaly them in the pivottable
If X.Name = "No Rep Info" Then X.Visible = True
If X.Name = Y Then X.Visible = True
'This is just to show what item the code is on during the loop.
MsgBox X.Name
Next X
End Sub
thanks in advance