Results 1 to 5 of 5

Manipulating a Column Label Filter on a Pivot using VBA

Threaded View

  1. #1
    Registered User
    Join Date
    06-29-2011
    Location
    Allen, TX
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    13

    Lightbulb Manipulating a Column Label Filter on a Pivot using VBA

    Hi,

    I'm new to VBA and I'm trying to write a simple procedure to alter the filter selections on a Pivot table using VBA.

    I am successful in manipulating the page fields (Pivot Filters) on the pivot using the following code, but have no idea on how to manipulate the column or row label field filters on the same table.

    Here is the code I have written so far and the Bold statement is the one I'm having trouble with:
    Public Sub Business()
    
    Application.ScreenUpdating = False
    
    Sheets("Global 360").PivotTables("G360").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("Chart Data").PivotTables("chart").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("Chart Data").PivotTables("chart").PivotFields("Site").CurrentPage = Sheets("2011 Summary").Range("U5").Value
    Sheets("Top 20").PivotTables("top20").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("Top 20").PivotTables("total").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("CF Pivot").PivotTables("CFSite").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("CF Pivot").PivotTables("CFCat").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("Top 20").PivotTables("SiteG360").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    Sheets("Top 20").PivotTables("SiteG360").PivotFilter("Site").DataField = Sheets("2011 Summary").Range("U5").Value
    Sheets("Top 20 Issues").PivotTables("Top").PivotFields("Site").CurrentPage = Sheets("2011 Summary").Range("U5").Value
    Sheets("Top 20 Issues").PivotTables("Top").PivotFields("Line Director").CurrentPage = Sheets("2011 Summary").Range("V5").Value
    
    
    Sheets("Chart Data").PivotTables("chart").PivotFields("OM").CurrentPage = "All"
    Sheets("Top 20").PivotTables("top20").PivotFields("OM").CurrentPage = "All"
    Sheets("Top 20").PivotTables("total").PivotFields("OM").CurrentPage = "All"
    Sheets("Top 20").PivotTables("SiteG360").PivotFields("OM").CurrentPage = "All"
    Application.ScreenUpdating = True
    
    End Sub
    Here is a snapshot of the pivot table:



    OM (All)
    Line Director (All)

    Count of Issue Site = Column Label / Filter
    Month Albuquerque Boise Chennai Florence Gray Greensboro
    Jan-11
    Feb-11
    Mar-11
    Apr-11
    May-11

    The error line is in Bold Typeface, the rest of the code works well!
    Any help on how I can update the column filter based on a value that is on another cell/sheet just like the page fields is what I'm looking for, and would be greatly appreciated!

    Thanks,
    Abhi
    Last edited by abhi.ko; 06-29-2011 at 08:18 PM.

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