ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Mulitcolumn listbox - Add Item (https://www.excelbanter.com/excel-programming/394851-mulitcolumn-listbox-add-item.html)

Helge's

Mulitcolumn listbox - Add Item
 
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


Dave Peterson

Mulitcolumn listbox - Add Item
 
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




Helge's wrote:

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


--

Dave Peterson

Helge's

Mulitcolumn listbox - Add Item
 
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

On 6 Aug, 14:02, Dave Peterson wrote:
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

Helge's wrote:

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


--

Dave Peterson




Dave Peterson

Mulitcolumn listbox - Add Item
 
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.

Helge's wrote:

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

On 6 Aug, 14:02, Dave Peterson wrote:
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

Helge's wrote:

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


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 11:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com