LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Member
 
Posts: 70
Default VBA Filtered Pivot Table Showing "Multiple Values Selected"; Only One Value Selected

I'm trying to loop through my pivot table items and filter on the value that matches a named range on another sheet. The looping and filtering works as expected. The problem is that when it's finished, although the pivot table is on the correct filtered value (and only one value is selected), it still shows "multiple selections" in the caption. Here is my code:

Code:
    Dim pt As PivotTable
    Dim Field As PivotField
    Dim Item As PivotItem    

'Filter based on previous workday's date
        Sheets("Note_Type_Summary").Select
        Set pt = Sheets("Note_Type_Summary").PivotTables("PivotTable1")
        Set Field = pt.PivotFields("NOTES_ENCOUNTER_DATE")
        pivotfiltervalue = Format(Sheets("Summary 25 Work Day").Range("RangeName"), "m/d/yyyy")
        Field.EnableItemSelection = False
        Field.ClearAllFilters
        
        For Each Item In Field.PivotItems
            Item.Visible = (Item.Caption = pivotfiltervalue)
        Next Item
As an aside, this line here works fine instead of looping through each item:
Code:
Sheets("Note_Type_Summary").PivotTables("PivotTable1").PivotFields("NOTES_ENCOUNTER_DATE").CurrentPage = pivotfiltervalue
However, it will only work for me. When my coworker tried to run this code on his computer, Excel crashed and restarted every time he got to that line in the code. If anyone knows of any reason why that is happening, that would be helpful as well. We are both using Excel 2007.

Any help is appreciated!
 
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
Storing Multiple Selected Pivot Table Report Filter Values [email protected] Excel Programming 2 September 8th 11 09:41 AM
Pivot Table Report Filter - "OR" instead of "AND" Multiple Filters tommcbrny Excel Discussion (Misc queries) 1 October 29th 09 03:08 AM
Pivot Table showing number "1" instead of actual result Pendelfin Excel Discussion (Misc queries) 1 May 20th 08 01:46 PM
how do I stop showing "blanks" in a pivot table? Borianita Excel Discussion (Misc queries) 2 April 30th 08 05:50 PM
if "a" selected from dropdown menu then show "K" in other cell LEGALMATTERS Excel Worksheet Functions 1 April 13th 06 06:05 PM


All times are GMT +1. The time now is 01:51 AM.

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

About Us

"It's about Microsoft Excel"