You have been so helpful to me already. I have another question and this is going to make my spreadsheet a zillion time better
This is my code. I took it from a helpful website. When I enter the pf.CurrentPage value directly into the code, (as below) this works perfectly. But what I really want is to set pf.CurrentPage to the value of a formula in C3. I tried doing pf.CurrentPage = "C3" but that gave me an error. That formula doesn't seem to work for some reason. Any thoughts?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'PURPOSE: Filter on a single item with the Report Filter field
'SOURCE: www.TheSpreadsheetGuru.com
Dim pf As PivotField
Set pf = ActiveSheet.PivotTables("PivotTable2").PivotFields("Cost Centre (Existing)")
'Clear Out Any Previous Filtering
pf.ClearAllFilters
'Filter on cost center
pf.CurrentPage = "3452"
End Sub
This is my code. I took it from a helpful website. When I enter the pf.CurrentPage value directly into the code, (as below) this works perfectly. But what I really want is to set pf.CurrentPage to the value of a formula in C3. I tried doing pf.CurrentPage = "C3" but that gave me an error. That formula doesn't seem to work for some reason. Any thoughts?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'PURPOSE: Filter on a single item with the Report Filter field
'SOURCE: www.TheSpreadsheetGuru.com
Dim pf As PivotField
Set pf = ActiveSheet.PivotTables("PivotTable2").PivotFields("Cost Centre (Existing)")
'Clear Out Any Previous Filtering
pf.ClearAllFilters
'Filter on cost center
pf.CurrentPage = "3452"
End Sub