+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Excel 2007 VBA to Clear Filters on Pivot Tables

Hybrid View

  1. #1
    Registered User
    Join Date
    03-26-2011
    Location
    York, PA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Excel 2007 VBA to Clear Filters on Pivot Tables

    I am trying to write code to clear any filters in pivot tables if they exist and running into a brick wall. I had been using the following code but its not working Any suggestions?

    Sheet1.Select
    If ActiveSheet.FilterMode Then
    ActiveSheet.ShowAllData
    End If
    Thanks for your help.
    Last edited by DonkeyOte; 03-27-2011 at 04:26 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Excel 2007 VBA to Clear Filters on Pivot Tables

    Hi

    Try something like

    Sub ClearFilters()
        Dim pt As PivotTable
        Dim pf As PivotField
        Set pt = ActiveSheet.PivotTables(1)
        On Error Resume Next
        For Each pf In pt.VisibleFields
            pf.ClearManualFilter
        Next pf
        On Error GoTo 0
    End Sub
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Excel 2007 VBA to Clear Filters on Pivot Tables

    @ckklconner, welcome to the board, however, please be sure when posting VBA to use CODE tags at all times (per Forum Rules).
    Given this was your first post I have on this occasion modified for you.

    Regards your question - for XL2007+ see: ClearAllFilters in VBE Help.

+ 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