Changing OlapCube pivot table filter - Error “Unable to set CurrentPage property of PivotField class” error

adamtg

New Member
Joined
Jun 17, 2016
Messages
1
HI,

I am trying to to change the the filter on a Pivot Table use the below VBA. I think the issue is with connecting to an Olap cube pivot table and not a normal pivot table. Highlighted in red is where the debug throws the error:

"Run-time error '1004':
Unable to set the CurrentPage property of the PivotField Class"

Any help would be appreciated




Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Intersect(Target, Range("C6:C7")) Is Nothing Then Exit Sub


Dim pt As PivotTable
Dim Field As PivotField
Dim SalesChannel As String
Dim Fields As PivotFields
Dim Name As String
Dim setValue As String

Set pt = Worksheets("Data").PivotTables("PivotTable1")
Set Fields = pt.PivotFields


For Each Field In Fields
Name = Field.Name
If Name = "[Sales Channel].[Sales Channel].[Sales Channel]" Then
Exit For
End If


Next


setValue = Worksheets("Tool").Range("C6").Value

With Field
.ClearAllFilters
.CurrentPage = setValue
End With


pt.RefreshTable
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,223,262
Messages
6,171,080
Members
452,377
Latest member
bradfordsam

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