Creating Macros with Cube Connections - Trying to use Combo Box with Cube generated PT

charlesutton

New Member
Joined
Sep 20, 2013
Messages
4
Hi Forum,

Trying to create a combo box that auto filters a cube generated pivot table. My code is provided below, but breaks at line 4. For some reason, the PT filter can't read the cell value in A54. Any help is greatly appreciated.

Sub StateChangeTest()

ActiveSheet.PivotTables("StateDropsPivot").PivotFields( _
"[Location].[State Name].[State Name]").ClearAllFilters
ActiveSheet.PivotTables("StateDropsPivot").PivotFields( _ <-- Breaks Here
"[Location].[State Name].[State Name]").CurrentPage = _
Worksheets("QuitDataState").Range("A54").Value

End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi charlesutton,

If the value in A54 is just a state name or code (say "Texas"), your current code tries to set the current page to "Texas"

For a cube source, you'll need to use a member expression like "[Location].[State Name].[All].[Texas]"

The exact expression will depend on the hierarchy of the cube. If you record a macro while manually setting that Report Filter, you can get the pattern.

If the pattern matched the example above you could build the expression like this....

Code:
sState = Worksheets("QuitDataState").Range("A54").Value

ActiveSheet.PivotTables("StateDropsPivot").PivotFields( _ 
 "[Location].[State Name].[State Name]").CurrentPage = _
 "[Location].[State Name].[All].[" & sState & "]"
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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