简体   繁体   中英

Multiple selections in EXCEL 2010 VBA AutoFilter

First, apologies for my English. I have this user form, where User needs to select a MONTH from lets say column C using a Toggle buttons. Multiple months should be possible to be selected at the same time eg I want to see results for January + February + May. I am filtering multiple columns for multiple criteria and at the last column I want to select more than one criteria at a time. Lets say I have a column A with all Names, then column B with year, Column C with Month and column D with Product. What I want to achieve with the user form is, to be able to filter out a single name (I have that done via ComboBox+AutoFilter) Then I want to select(filter) a Year (have done that via ToggleButton+AutoFilter) and then I need to filter multiple entries in the MONTH column (For example I want to see what products Jon Doe bought in year 2015 in the months of January + May + September. Then I would like to copy all these filtered entries (those visible rows) and copy/paste them into new sheet.

So I have set up these "Month" buttons, I'm able to select ONE month at a time, but not multiple. Can you please advise how can I accomplish this ? If the toggle buttons are not the good way to do the selection, please advise some other.

I even thought out of not using the AUTO FILTER for the MONTH column, but to use something like: From the already filtered rows go down and find string "January" or "May" or "September" within the visible rows and when you find such row mark it(or select it) and continue searching until first empty row. Then copy all the rows that match the search criteria and copy/paste them to this "new sheet".

But I'm a beginner lama and can't find a way of doing this right. Please advise.

Autofilters allow for multiple selection. Recording a macro will give you the code you need for that.

In your userform, there should be a property of the listbox that allows multiple selection as well.

Should be a relatively straightforward exercise of looping through selected items in the listbox and applying the criteria to the autofilter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM