Slicer Selection based on Cells

Sasnak

New Member
Joined
Jan 9, 2015
Messages
2
Dear All,

this is my first post and I hope I stick to the rules.

I have the following problem. I have a pivot graph connected to a slicer with different company names. In a different flat Pivot table I list the companies by market share and I would now like to only select the first 4 Companies by market share for the previously mentioned pivot graph.

I tried selecting the Companies manually and record my macro which looks like this:

Sub TopFiveCompanies()
'
' TopFiveCompanies Macro
'
' Keyboard Shortcut: Ctrl+Shift+T
'
ActiveWorkbook.SlicerCaches("Slicer_Company").VisibleSlicerItemsList = Array( _
"[All Data Table 1].[Company].&[Company A]")
ActiveWorkbook.SlicerCaches("Slicer_Company").VisibleSlicerItemsList = Array( _
"[All Data Table 1].[Company].&[Company D]", "[All Data Table 1].[Company].&[Company C]" _
, "[All Data Table 1].[Company].&[Company B]", _
"[All Data Table 1].[Company].&[Company A]")
End Sub

I now somehow need to link the Companies to their respective cells:
Company A = B30
Company B = B31
Company C = B32
Company D = B33

I am not quite sure if this way even works, but it seemed the easiest way at first. I also tried googling the problem but could not find a solution that worked for me.

Any help is appreciated.

Thank you!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
In the meantime, I have been able to narrow it down to the following:

Sub BestofSelection()
Dim i As Integer
Dim MemberID As String
Application.ScreenUpdating = False
ThisWorkbook.SlicerCaches("Slicer_Company").ClearManualFilter
ID = ThisWorkbook.Worksheets("Sheet1").Cells(1, 1).Value
ThisWorkbook.SlicerCaches("Slicer_Company").SlicerItems(ID).Selected = True

Application.ScreenUpdating = True
End Sub

The Filter clearing as well as the selection of Cell A1 work fine but the new slicer selection of that certain item does not work yet.

Any ideas? Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,965
Members
449,201
Latest member
Jamil ahmed

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