PDA

View Full Version : Best (and smart) way to do ListBox Filter



lipse
10-23-2011, 07:11 PM
Hi Everyone, my first post here!
First of all sorry about my English, and, yes! im a macro newbie.

Im doing a project to do a dynamically report using filters.
These filters will be make using various listbox (5~7). The user will select a option in a listbox and the report will refresh automatically, select other option in other listbox and then refresh again.... and go...

Im dont have the code yet (im thinking now about the code), but im thinking how i do that...
I think about a module (procedure) to apply various autofilters (Worksheets("").Range("A1").Autofilter bla bla bla), and after each user selection ill refresh the worksheet (using change event from listbox), but im releasing this idea because how can i do when user release the filter from one listbox? Store every filter in array and apply everyone again?
I thinked about Advanced Filtering, but, i dont know how to use and in my point isnt the better way...
So... im here to ask for help, im trying to obtain a "better way" from you... expert`s...

Thanks in advance.

mdmackillop
10-24-2011, 06:01 AM
Hi Lipse
Welcome to VBAX
Can you post a workbook with your layout etc. and sample data, also what you are looking for in the way of a report. Use Manage Attachments in the GoAdvanced reply section.

lipse
10-24-2011, 05:56 PM
Hi mdmackillop, Thx for quick reply!
Im attached at this post a example (not the original base, because im building it) for what i wanna do.
A Worksheet, that comboboxes will be used to select data for filtering (like autofilter).
This is my ideas:

1) Build Worksheet with "RAW" Data
2) Sort This Worksheet
3) Apply Unique constraint for all columns and rows, and put result in other Worksheet
4) Set RowSource for each combobox according each specified (unique) column.
5) When user change (i will use the event) a combobox, the selected filter will be applied to other sheet having a report, using as base the RAW Data.

The resumed ideia is...
- Create Raw data Worksheet
- Filter Raw data using combo boxes
- Execute functions (like count and sum)
- Show results in report Worksheet

Do you understand?

Thanks in advance... Again.