+ Reply to Thread
Results 1 to 1 of 1

VBA Code - Changing filters of several pivot tables based on cell values

Hybrid View

  1. #1
    Registered User
    Join Date
    12-14-2010
    Location
    DC, USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    VBA Code - Changing filters of several pivot tables based on cell values

    Hi,

    I was able to use TJ's code from this post perfectly for only one value and one pivot table.

    However, now I need to update multiple pivot tables - all with the same filters/pages - in different spreadsheets.

    The spreadsheet with the values that should change the filter is "Setup" and then I have about 5 other spreadsheets all with pivot tables, and two other sheets with the data feeding the pivot tables.

    This is what I have:
    Sub Apply_Name_Filter()
        Dim pvtTable As PivotTable
        Dim pvtField As PivotField
        Dim pvtItem As PivotItem
        Dim filterName As String
        
        Set pvtTable = Worksheets("PIVOT-Sheet2").PivotTables("PivotTable1")
        Set pvtField = pvtTable.PivotFields("Name")
        
        filterName = Worksheets("Setup").Range("B8")
        
        For Each pvtItem In pvtField.PivotItems
            If pvtItem.Value = filterName Then
                pvtField.CurrentPage = filterName
                Exit For
            End If
        Next pvtItem
    
    End Sub
    Any suggestions in what I could do? (I'm a beginner at coding.... ;-)
    Thanks!
    Last edited by kriskrispies; 12-15-2010 at 09:54 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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