Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Specific Item in Specific Field
I am trying to execute a command where a user can input the criteria that
they want and have the pivot table show the specified item in the field they want filtered. I am using the code below, however, it does not completely erase the last item that was selected in the field value. It will always keep two items displayed. IS there a problem in the code below? Also, how can I make this selection apply to more than one pivot table, would like this selection to feed 4 different tables. Sub Selection() Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem Dim strPromptPF As String Dim strPromptPI As String Dim strPF As String Dim strPI As String strPromptPF = "Please enter the name of the field you wish to filter." strPromptPI = "Please enter the item you wish to filter for." Set pt = ActiveSheet.PivotTables("PivotTable1") strPF = InputBox(strPromptPF, "Enter Field Name") strPI = InputBox(strPromptPI, "Enter Item") Set pf = pt.PivotFields(strPF) Application.ScreenUpdating = False Application.DisplayAlerts = False On Error Resume Next With pf .AutoSort xlManual, .SourceName For Each pi In pf.PivotItems pi.Visible = False Next pi .PivotItems(strPI).Visible = True .AutoSort xlAscending, .SourceName End With Application.DisplayAlerts = True Application.ScreenUpdating = True ' End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Vlookup with a specific item | Excel Discussion (Misc queries) | |||
Selectin an specific item on the spreadsheet. | Excel Discussion (Misc queries) | |||
Count Specific Item in Specific Row | Excel Discussion (Misc queries) | |||
how to count specific item??? | Excel Discussion (Misc queries) | |||
Hide all PivotItems except for a specific Item | Excel Programming |