Slicer Items in ComboBox

mightymike

Board Regular
Joined
Feb 11, 2010
Messages
127
Hi all,

Hoping somebody could help me on this one.

I have a pivot table linked to a SQL database which in this instance I thought I would use the slicer tool for filtering as it looks nicer than the usual report filter.

I would like to put the data of one of the slicers into a combo box, bit like how you would with pivotitems.

For the life of me I cant work out the correct code for it, could anybody help?

This is my feeble attempt..

Code:
Dim SLSP As SlicerItem

Me.CBSalesPerson.Clear

For Each SLSP In Sheets("Order Book").Slicer("Sales Person").SlicerItems

  Me.CBSalesPerson.AddItem SLSP.Name

Next

Thanks in advance.

Mike
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This worked for me:

Rich (BB code):
Private Sub UserForm_Initialize()
    Dim SLSP As SlicerItem
    Me.CBSalesPerson.Clear
    For Each SLSP In Worksheets("Order Book").PivotTables(1).Slicers("Sales Person").SlicerCache.SlicerItems
        Me.CBSalesPerson.AddItem SLSP.Name
    Next SLSP
End Sub
 
Upvote 0
Thank you very much Andrew, works perfectly.

First time using slicers so not so familiar with the VBA code :(

Thanks again.

Mike
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,727
Members
449,049
Latest member
MiguekHeka

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