Fill a Listbox from a filtered Table with more them 10 columns

Its not working if i have more then 10 columns

Any help?
Photo GP Photo GPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
This example demonstrates how to load more than 10 columns. Note if you have set the RowSource manually then remove it in the ListBox's properties.

I need to see your code to see how you are actually populating the ListBox with filtered data.
Populate-ListBox.xlsm
1
Roy CoxGroup Finance ManagerCommented:
I'm out visiting family now, but here's an example of filtering data on a UserForm.

I'll check in when I get home to see if you need help applying it to your workbook
FilterForm--1-.xlsm
1
Photo GP Photo GPAuthor Commented:
Hi Roy
Many thanks for your answers.

My problem is simpler, but it's the combination of both of the solutions you've presented, but it's still confusing for a beginner in VBA.

I have a table with 16 columns (and a variable number of rows), the column number 16 only has "True" and "False", and I want to load a ListBox, with the first 12 columns of the table, when the value of column number 16 is "True ".

I would  like to know how to put, or not the headers in the ListBox.

Many thanks
Jorge
Populate-ListBox_ExpertExchange.xlsm
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Roy CoxGroup Finance ManagerCommented:
Because you are using a Table for code is simplified. We can use the Tables structured ranges - DataBodyRange to load without the headers and the whole Table to include headers,

However to show the Table as a Filtered Range I'll need to add some code to filter to a temporary Table then load the UserForm.

Here's the basic code. I'll amend my code to load the filtered range for you and post back later.

It might be tomorrow before I can finish this for you
Populate-ListBox_ExpertExchange.xlsm
1
Roy CoxGroup Finance ManagerCommented:
Here's a working example for you. I'll tidy it up and add some explanation tomorrow
Populate-ListBox_ExpertExchange.xlsm
1
Photo GP Photo GPAuthor Commented:
Roy thanks , but first line its not working as a Headers
0
Roy CoxGroup Finance ManagerCommented:
One ListBox includes the Headers, isn't that what you mean?

I'll check tomorrow.
0
Photo GP Photo GPAuthor Commented:
Yes Roy, but something strange happens since the header does not behave as such since it is also selectable.

And the auxiliary table is always changing its name so the routine gives error in the second execution. I'll wait for tomorrow.

Many thanks for your tips.

Best Regards
Jorge
0
Roy CoxGroup Finance ManagerCommented:
I'm made changes and just need to check completely. I'll post a revised example later.
1
Roy CoxGroup Finance ManagerCommented:
I've made quite a lot of changes here.

1. Fixed your "button" to stop it shrinking when filer is applied.
2. The Header Row functions properly, in my haste last night I missed some code.
3. Filtered data is copied to a hidden sheet which populates the ListBoxes.
4. Labels indicate how many records are displayed.
5. Added some error handling.

If I get time this weekend I'll look at improving the code.
Populate-ListBox_ExpertExchange-2-.xlsm
1
Photo GP Photo GPAuthor Commented:
Hi Roy
Almost perfect, the only problem I see and I can not understand the reason is that the ListBox without the header is doing the filter correctly and the Listbox with header does not, i attach a screen capture. I had to change the values of the ComboBox in order to adapt to my language, Portuguese.

And the format is also diferente Columns 4, 5 and 11 should be in percentage and they are in the ListBox with the Header but not in the other, why?

Thank you one more time

A great Easter for you.
Jorge
ListBox-Filtered.PNG
0
Roy CoxGroup Finance ManagerCommented:
Is the only discrepancy the %? I'm sure the filter is correct.

I hadn't noticed the % difference, it must be because one method uses RowSource to populate the ListBox, the other uses the List property which seems to convert the contents to values.
Populate-ListBox_ExpertExchange-3-.xlsm
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Photo GP Photo GPAuthor Commented:
Hi Roy

I had to make some adjustments to your code, I do not know why, but the filter is not working properly, although both the code is correct and the values in the tables are also correct after the filter is applied.
Maybe some problem with my excel (2016).

Just one last question, is it possible, just, to center the ListBox header?

Thanks again

Jorge Cabral
Populate-ListBox_ExpertExchange-3-1.xlsm
0
Roy CoxGroup Finance ManagerCommented:
Why is the filter not working?

You cannot change the layout of the ListBox unfortunately
0
Photo GP Photo GPAuthor Commented:
I can’t explain. See the image i send you. The values in both ListBox should be the same.
0
Roy CoxGroup Finance ManagerCommented:
I've fixed the percentages in my last upload. When I fileter on my computer the lists are the same.
1
Photo GP Photo GPAuthor Commented:
Many thanks for your help and your solution, if any improvements send me by email.
0
Roy CoxGroup Finance ManagerCommented:
Pleased to help. If I amend the code I'll post here.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.