+ Reply to Thread
Results 1 to 10 of 10

Filter on pivot table values after pivotupdate event

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,945

    Filter on pivot table values after pivotupdate event

    Hi Guys,

    i have pivot table like here:
    Screenshot_1.png

    and what i want is to add filter on values to exclude values <> 0.
    Manually when i am setting this up it is working like a charm without any issues.

    I recorded even macro to this via VBA but i am getting error:
    Autofilter method of range class failed.

    Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
    
    Dim AddressPivot As Range
    Dim strAddress As String
    
        ActiveSheet.Range("$A$1:$C$10").AutoFilter Field:=3, Criteria1:=Array("165" _
            , "22", "55", "88"), Operator:=xlFilterValues
            
        ActiveSheet.Range("$A$1:$C$10").AutoFilter Field:=3
     
    End Sub
    Code to this is like above.
    The perfect solution would be to take address from target pivot table and use it to filter specific field.

    Please help,
    Jacek
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-20-2007
    Location
    Felixstowe, England
    MS-Off Ver
    Excel 2013, 2019
    Posts
    217

    Re: Filter on pivot table values after pivotupdate event

    Have you considered also putting the age in the Report Page filter area, multiple items option, and unticking 0?

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,945

    Re: Filter on pivot table values after pivotupdate event

    Hi,

    I didnt think about it.
    It will be reaplying after refreshing table?

    Best,
    Jacek

  4. #4
    Forum Contributor
    Join Date
    11-20-2007
    Location
    Felixstowe, England
    MS-Off Ver
    Excel 2013, 2019
    Posts
    217

    Re: Filter on pivot table values after pivotupdate event

    Thinking about it further, can I ask whether you can have a new extra column in the data? A simple flag of a formula of =C2>0 type of thing ... giving either TRUE or FALSE, and use that in the Report Page filter ... it will be correct on refresh then.

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,945

    Re: Filter on pivot table values after pivotupdate event

    Hmm it is not working after refreshing.

    I have to still do this manually...

    Jacek

  6. #6
    Forum Contributor
    Join Date
    11-20-2007
    Location
    Felixstowe, England
    MS-Off Ver
    Excel 2013, 2019
    Posts
    217

    Re: Filter on pivot table values after pivotupdate event

    Quote Originally Posted by jaryszek View Post
    Hmm it is not working after refreshing.

    I have to still do this manually...

    Jacek
    What isn't? My suggestion of having an extra column, then putting it in the Report Page filter works fine ... see attached:
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,945

    Re: Filter on pivot table values after pivotupdate event

    Ok but this can work using something like:

        ActiveSheet.PivotTables("PivotTable1").PivotFields("TotalServers").CurrentPage _
            = "(All)"
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("TotalServers")
            .PivotItems("1").Visible = True
        End With
        ActiveSheet.PivotTables("PivotTable1").PivotFields("TotalServers"). _
            EnableMultiplePageItems = True
    If i will create filter field in my pivot table.
    How to add criteria to make this "<>0"?

    Please help,
    Jacek

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,945

    Re: Filter on pivot table values after pivotupdate event

    Ok it is working.

    Thank you. But with my specific client i can not add additional column.

    Do you know maybe how to create code for filtering in VBA?

    Jacek

  9. #9
    Forum Contributor
    Join Date
    11-20-2007
    Location
    Felixstowe, England
    MS-Off Ver
    Excel 2013, 2019
    Posts
    217

    Re: Filter on pivot table values after pivotupdate event

    Ah, OK. Well, can you see if this does what you want:

            On Error Resume Next
            For Each pt In ActiveSheet.PivotTables("PivotTable1").PivotFields("TotalServers").PivotItems
                pt.Visible = True
            Next
            On Error GoTo 0
            With ActiveSheet.PivotTables("PivotTable1").PivotFields("TotalServers")
                .PivotItems("0").Visible = False
            End With

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,945

    Re: Filter on pivot table values after pivotupdate event

    Thank you!!!

    Jacek

+ 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. [SOLVED] Deactive Pivotupdate while updating Filter VBA
    By andershess in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2017, 09:07 AM
  2. Replies: 2
    Last Post: 12-18-2016, 08:37 PM
  3. Filter values in pivot table
    By netskyblue in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 05-24-2016, 05:07 AM
  4. Pivot table Filter event
    By haissk in forum Excel General
    Replies: 2
    Last Post: 07-10-2014, 08:45 AM
  5. [SOLVED] How do I filter Pivot Table Values?
    By flyboy54 in forum Excel Charting & Pivots
    Replies: 21
    Last Post: 05-24-2013, 10:17 AM
  6. Excel 2007 : How to Filter TOP 5 Values in PIVOT Table
    By yourskarthik in forum Excel General
    Replies: 3
    Last Post: 12-30-2009, 11:26 AM
  7. filter pivot table with multiple values?
    By hamsup1o in forum Excel General
    Replies: 0
    Last Post: 09-29-2009, 04:08 PM

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