How to Code Multiselct List Box to use as a Filter

ccsher77

New Member
Joined
Apr 7, 2011
Messages
12
Hi Everyone,

OK, I have a Spread sheet with a userform which has a list box listing unique numbers for a certain column (column B).
I have manged to set it up so that when I Select a number fro the list box and press the command button the macro basically filters the worksheet and only displays the data row of the selected number (from the listbox).

Wha I need to do is expand on this so that I can allow the user to select multipl numbers from the list box and when the command button is pressed the macro will display the rows for the selection (if that makes sense?)

I have placed the code I have put together so far below,

Any help would be much appreciated.


Code:
Private Sub CommandButton1_Click()
 Sheets("Mar").Range("B4:B100").AutoFilter
    ActiveSheet.Range("$B$4:$O$100").AutoFilter Field:=1, Criteria1:=ListBox1.List
End Sub
Private Sub CommandButton2_Click()
ActiveSheet.Range("$A$2:$D$6").AutoFilter Field:=1
Rows("4:4").Select
    Selection.AutoFilter
    Range("A1").Select
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

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