+ Reply to Thread
Results 1 to 4 of 4

Selecting criteria in Pivot table

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Selecting criteria in Pivot table

    I need to know how to make a one size fits all selection for my pivot tables. The overall situation is; I have 12 regions, each of which has an Expense Report. I want to open each workbook, and configure the pivot tables the same. The problem I'm getting into is in regards to the "Strategy". I only want 11001and 11002 to show. All regions have these. However, there are tons of other strategies, and the mix differs by region. If have these these turned (as shown in my code below), I get an error if the value doesn't exist. If I don't turn them off, all show. How do I work around this?

    Please Login or Register  to view this content.
    Last edited by Mordred; 08-30-2011 at 01:10 PM.

  2. #2
    Registered User
    Join Date
    08-18-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Selecting criteria in Pivot table

    Set pvtTable = ActiveSheet.PivotTables("PivotTable1")


    For Each pvtItem In pvtTable.PivotFields("MFR_STRATEGY").PivotItems
    If pvtItem = "11001" or pvtItem = "11002" Then
    pvtItem.Visible = True
    Else
    pvtItem.Visible = False
    End If
    Next

    This could work?

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Selecting criteria in Pivot table

    I'm excited about the possiblity, but am having trouble implementing. The code below is my first attempt. Notice I dimmed pvtItem as PivotItem. When I try to run the code, it sticks on the line beginning "For each pvtItem..." with the error message
    Please Login or Register  to view this content.
    Any help in getting through that is greatly appreciated.
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Selecting criteria in Pivot table

    Never mind. Sometimes I'm just too thick to believe! "MFR_STRATEGY" is not the same thing as "FY 10-11 Strategy". That's what I get for trying to go from memory.

    The code works great! That one's gonna go in my toolbox!

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1