List box problems

garyd1234

Board Regular
Joined
Apr 17, 2003
Messages
103
How do you put /get items out of column 2 of a 2 column list box?

list42.column(1,list42.listindex) Is this correct and, if so, what do you set listindex = to. My list box populates from a query. I want to write a loop that reads down through the items in the list box and compare the first column item in each row with another variable to search and pull out the second item (second column).

Need help on how to load up a list box in code and get stuff out. List42.additem won't work like it does in VB.
Like Avril Lavigne says "Why'd they have to go and make things so complicated?"
Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi garyd1234,

I think the easiest way is to set your listbox's rowsource property to a table or SQL expression. Then set the column count to 2, and set your column widths to something like:
1";1";
adjust to suit your needs

To add/remove items, do something that changes the criteria for a query, or delete or add records for a table source.

Use
Listbox1.requery to keep your listbox's contents fresh after you've altered its source data. Adjust the name listbox1 for your control.

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,525
Messages
6,160,327
Members
451,637
Latest member
hvp2262

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