• 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.

Pivot Table with VBA error

cacos

Member
Hi! I'm using vba to filter a pivot table given specific values.


This is probably pretty basic, but I can't get it to run if the sheet is hidden, or if I'm on another sheet.


Here's the code:

[pre]
Code:
Sub Filter()
Dim pt As PivotTable
Set pt = Sheets(4).PivotTables("PivotTable2")

pt.ClearAllFilters
pt.PivotFields("Filter1").CurrentPage = Range("O1").Value
pt.PivotFields("Filter2").CurrentPage = Range("O2").Value
pt.PivotFields("Filter3").CurrentPage = Range("O3").Value

End Sub
[/pre]

Thanks!
 
Back
Top