VBA PivotT filter: Unable to get the pivotfields property of the worksheet class.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
765
Hello friends, Hope all is well!

The VB has a bug. Trying to filter a PivotTable with a cell value (CB2).
I got the bug: unable to get the pivotfields property of the worksheet class

And the following line is highlighted: Set xPFile = xPTable.PivotFields("Month")

Your kind & continuous help is needed and always appreciated.

Code:
Sub Slice1()
    
    Dim xPTable As PivotTable
    Dim xPFile As PivotField
    Dim xStr As String
    Application.ScreenUpdating = False
    Set xPTable = Worksheets("RNO").PivotTables("RNO1")
    Set xPFile = xPTable.PivotFields("Month")
            
    
    xStr = M = Worksheets("RNO").Range("CB2").Value
    xPFile.ClearAllFilters
    xPFile.CurrentPage = xStr
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
In the pivot table you must have a field with the name "Month"


Also change this line:

Code:
[COLOR=#333333]xStr = Worksheets("RNO").Range("CB2").Value[/COLOR]
 
Upvote 0
thank you very much! But still, I am now getting:
unable to get the pivotfields property of the pivottable class
highlight on line: Set xPFile = xPTable.PivotFields("Month")

Your kind help please. Thanks again
 
Upvote 0
thank you very much! But still, I am now getting:
unable to get the pivotfields property of the pivottable class
highlight on line: Set xPFile = xPTable.PivotFields("Month")

Your kind help please. Thanks again

It works for me, you could upload a copy of your file to review it.
You can upload it to dropbox.com If it contains confidential data, you can change it to general data.
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top