Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlookup with a specific item kattay Excel Discussion (Misc queries) 1 December 23rd 09 07:21 AM
Selectin an specific item on the spreadsheet. Gmata Excel Discussion (Misc queries) 4 April 8th 09 06:52 PM
Count Specific Item in Specific Row RayH Excel Discussion (Misc queries) 9 July 23rd 06 07:48 PM
how to count specific item??? Jeff32 Excel Discussion (Misc queries) 2 May 7th 06 05:38 PM
Hide all PivotItems except for a specific Item DynamiteSkippy Excel Programming 1 July 15th 05 12:23 AM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"