Mulitcolumn listbox - Add Item

  • Thread starter Thread starter Helge's
  • Start date Start date
H

Helge's

How do I add a row with two values in a listbox?

I thought I could just do

listbox.additem("a1","a2")

but it does not work.

Helge
 
Maybe...

dim myRng as range
dim myCell as range

set myrng = worksheets("somesheethere").range("a1:A10")

for each mycell in myrng.cells
With me.listbox1
.AddItem myCell.Value
.List(.ListCount - 1, 1) = myCell.Offset(0, 1).Value
end with
next mycell

========
Depending on what you're doing, you may be able to do it in one step.

me.listbox1.list = worksheets("somesheethere").range("a1:b10").value
 
Thank you very much.

What I want to do is to take data from a database with ADO and put it
in a listbox with several columns. Then I thougth additem should be
quite easy.

Helge
 
I don't use ADO, but I would think that once you got your data refreshed in a
worksheet (via ADO???), then the code would work ok.

But that's a guess.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top