Using VBA to create Multi Select ListBox to Filter Pivot Tables

Bdude11383

New Member
Joined
Jun 16, 2011
Messages
1
Hello fellow Mr. Excel fans,

I'm trying to create a multi-select list box that will allow users to filter a group of pivot tables based on their list box selection(s). My list box code is below. The code only succeeds at filtering the last selection chosen in the list box by the user, however I would like the pivot tables to be filtered by all of the selections in the list box. If anyone has an idea on how to fix this, I would be extremely appreciative.

Thanks in advance!
Bdude11383

- - - - - - - -

Private Sub cmdStep2_Click()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

Dim i As Integer<o:p></o:p>

Sheets("Direct Lease vs Sublet").PivotTables("PivotTable1").PivotFields("GeographyName").ClearAllFilters<o:p></o:p>
Sheets("Direct Lease vs Sublet").PivotTables("PivotTable1").PivotFields("GeographyName").EnableMultiplePageItems = True<o:p></o:p>

For i = 0 To SubMarketsListBox.ListCount - 1<o:p></o:p>
If SubMarketsListBox.Selected(i) = True Then _<o:p></o:p>
Sheets("Direct Lease vs Sublet").PivotTables("PivotTable1").PivotFields("GeographyName").CurrentPage = _<o:p></o:p>
SubMarketsListBox.List(i)<o:p></o:p>
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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