Good afternoon all,
I have come across an issue with a piece of VB code Ihave been using to auto filter another pivot table based on a cell reference and I am a bit lost.
The working code below works in other files but fails on the "Set pvFld" with error "unable to get the PivotFields property of the PivotTable class
So i recorded a macro of me doing this manually (bottom code" and the code looks totally different. Is there away to write this so the cell value can be used?
This is the first time I have come across this error as when I record the original steps in a working file, it doesnt look like anything from the one below, the only difference the current pivottable has an added measure in it
Working code in another file
recorded Macro
thanks in advance
Gavin
I have come across an issue with a piece of VB code Ihave been using to auto filter another pivot table based on a cell reference and I am a bit lost.
The working code below works in other files but fails on the "Set pvFld" with error "unable to get the PivotFields property of the PivotTable class
So i recorded a macro of me doing this manually (bottom code" and the code looks totally different. Is there away to write this so the cell value can be used?
This is the first time I have come across this error as when I record the original steps in a working file, it doesnt look like anything from the one below, the only difference the current pivottable has an added measure in it
Working code in another file
Code:
Sheets("Pivot").Select
Range("H10").Select
ActiveSheet.PivotTables("PivotTable1").ClearAllFilters
Set pvFld = ActiveSheet.PivotTables("PivotTable1").PivotFields("Week No")
strFilter = ActiveWorkbook.Sheets("Pivot").Range("B4").Value
pvFld.CurrentPage = strFilter
recorded Macro
Code:
Range("Q14").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveSheet.PivotTables("PivotTable5").PivotFields( _
"[Table_OldestCase].[Week No].[Week No]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable5").PivotFields( _
"[Table_OldestCase].[Week No].[Week No]").CurrentPageName = _
"[Table_OldestCase].[Week No].&[5]"
thanks in advance
Gavin