Results 1 to 4 of 4

Thread: Filter Pivot table by cell

  1. #1

    Filter Pivot table by cell



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hey,

    I am a little rusty with vba these days.

    I am trying to filter my pivot table by linking it to a cell on a seperate worksheet. This is what I have but I keep getting an error message. I am using excel 2007.

    Code:
    Sub Tourname()
    '
    ' To filter PT by tour
    '
    '
        wrkshtpt.PivotTables("PivotTable1").PivotFields("Tour name").ClearAllFilters
        wrkshtpt.PivotTables("PivotTable1").PivotFields("Tour name").Sheets("wrkshtcmw").Range ("B1")
    End Sub
    Thanks!,

    Brandon

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,271
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Hey Brandon!

    Sorry for the late reply here. You're on the right track, but you need to set your filter equal to something:

    Code:
    Sub Tourname()
    '
    ' To filter PT by tour
    '
    '
    wrkshtpt.PivotTables("PivotTable1").PivotFields("Tour name").ClearAllFilters
    wrkshtpt.PivotTables("PivotTable1").PivotFields("Tour name").CurrentPage = Worksheets("wrkshtcmw").Range ("B1").Value
    End Sub
    Assuming that you're trying to set the page field, of course.

    Hope things are well with you!
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    Thanks Ken!,

    Things are going well. I am starting to get pretty busy.

    I hope things are gong well with you!

    Cheers,

  4. #4
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,271
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Things are great, but I know all about busy, for sure!
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

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