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]
[/pre]
Thanks!
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
Thanks!