countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 758
Hello friends, hope all is well.
I am trying to have a code that goes to a cell, picks up the date, and applies it to the filtered field of the pivot/power pivot.
I am getting an error (run-time error '1004' unable to set the currentpage property of the pivotfield class).
after debugging I get the following highlighted:
Please help me make the code run without errors.
Thanks a lot in advance!
I am trying to have a code that goes to a cell, picks up the date, and applies it to the filtered field of the pivot/power pivot.
I am getting an error (run-time error '1004' unable to set the currentpage property of the pivotfield class).
after debugging I get the following highlighted:
Code:
.CurrentPage = "All"
Please help me make the code run without errors.
Thanks a lot in advance!
Code:
Sub FilterMonth()
Dim pt As PivotTable
Dim Field As PivotField
Dim Stng As String
'defining the pivot table and the field
Set pt = Worksheets("Pivot").PivotTables("PivotTable1")
Set Field = pt.PivotFields("[dr salary database].[month].[month]")
'the date value
Stng = Worksheets("summary").Range("m4").Value
With Field
.ClearAllFilters
'this line below doesn't work
.CurrentPage = "All"
pt.RefreshTable
End With
End Sub