• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Report filter in page filed in pivot table

Nitin Suntwal

New Member
Very Good Morning Team,

Need your help on filtering pivot table.

I have created a pivot report. What I am looking in is everytime vba should select all the page filed items except the last one. Below is the code i am trying to figure it out with.

Sub asdfasf()
With Sheets("SalesPivot").PivotTables("PivotTable1").PageFields("OrderDate")
For i = 1 To .PivotItems.Count - 1
.PivotItems(.PivotItems(i).Name).Visible = True
Next i
End With
End Sub

Attached is the file for your reference. Thanks for you help.
 

Attachments

  • pivotitemsshowhide.xlsm
    57.6 KB · Views: 2
Something like below?
Code:
Sub asdfasf()
With Sheets("SalesPivot").PivotTables("PivotTable1").PageFields("OrderDate")
    For i = 1 To .PivotItems.Count
        If i < .PivotItems.Count Then
            .PivotItems(i).Visible = True
        Else
            .PivotItems(i).Visible = False
        End If
    Next i
End With
End Sub
 
Details. Without you telling me exactly how it's not working. Can't really help you.

Also detail exactly what the end result of code should show. Above code does what exactly you asked. When it's run, it will show all but the last PivotItem in the PivotField/PageField.
 
Some magic happened morning I have copied the same code & tried to run vba was througing error & finally I replied as not working. & now I tried it the same now its working. Sorry to trouble you.
Thank
 
Back
Top