Good afternoon,
I have a couple of tables I want to filter using VB instead of a slicer as the pivot table come from 2 different tables and I cant use 1 slicer to do both tables.
I have worked some code (example1 below) which works on all my pivot tables bar the final one I have created and I think the reason is because the final pivot table is doing a distinct count.
I am trying to filter based on a week Number ("B18")
Is there a way to adapt my code to do the second part or how would I amend my code to align the "&[3] to my Range("B18")
Or is there a better way to do this?
thanks in advance
Gavin
I have a couple of tables I want to filter using VB instead of a slicer as the pivot table come from 2 different tables and I cant use 1 slicer to do both tables.
I have worked some code (example1 below) which works on all my pivot tables bar the final one I have created and I think the reason is because the final pivot table is doing a distinct count.
I am trying to filter based on a week Number ("B18")
Is there a way to adapt my code to do the second part or how would I amend my code to align the "&[3] to my Range("B18")
Or is there a better way to do this?
Code:
Example 1
Sheets("SheetName").Select
Range("AJ2").Select
Set pvFld = ActiveSheet.PivotTables("PivotTable37").PivotFields("Week No")
strFilter = ActiveWorkbook.Sheets("SheetName").Range("B18").Value
pvFld.CurrentPage = strFilter
Recorded Macro
ActiveSheet.PivotTables("PivotTable42").PivotFields( _
"[CAllTypeAHT 1].[Week No].[Week No]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable42").PivotFields( _
"[CAllTypeAHT 1].[Week No].[Week No]").CurrentPageName = _
"[CAllTypeAHT 1].[Week No].&[3]"
Gavin