+ Reply to Thread
Results 1 to 3 of 3

Filter a pivot given a list Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    07-14-2017
    Location
    Toronto
    MS-Off Ver
    Excel 2016
    Posts
    6

    Filter a pivot given a list Macro

    I have a pivot table I would to filter using a list of data in a table using a macro

    the table looks like this

    table.JPG


    and the pivot table has a filter for Region

    If the table says keep in column 2 then I want the pivot table to filter the Region to include that region and not include the ones that say remove

  2. #2
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Filter a pivot given a list Macro

    May not be the prettiest solution but I think this should work:
    Sub help()
    Dim i As Integer
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Region")
        For i = 3 To 8
            If Cells(i, 2).Value = "Keep" Then
            End If
            If Cells(i, 2).Value = "Remove" Then
                .PivotItems(Cells(i, 1).Value).Visible = False
            End If
            Next i
        End With
    End Sub
    This assumes your table is exactly where you show it in the screenshot, that your PivotTable heading is "Region", and that you are starting with all Regions visible

  3. #3
    Registered User
    Join Date
    07-14-2017
    Location
    Toronto
    MS-Off Ver
    Excel 2016
    Posts
    6

    Re: Filter a pivot given a list Macro

    Awesome thanks for the quick reply I will check it out

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Filter Pivot From List
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2015, 03:27 PM
  2. Macro to filter a pivot whilst looping through filter criteria in a variable list.
    By Alistairm88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2015, 04:25 AM
  3. Get list of filtered values from pivot filter
    By mateoc15 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2015, 10:21 AM
  4. [SOLVED] Use A Custom List of Values To Filter Pivot Table
    By dollylectric in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-29-2013, 01:05 PM
  5. [SOLVED] Filter a pivot table by list in a range
    By MikeWard100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2012, 07:31 PM
  6. Customize Filter List in Pivot Tables
    By kstrait@gmail.com in forum Excel General
    Replies: 0
    Last Post: 08-09-2006, 12:10 AM
  7. [SOLVED] Customize Filter List in Pivot Tables
    By kstrait@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2006, 12:10 AM

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