Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Double click item in Listbox to select item and close Listbox GusEvans Excel Programming 3 July 19th 07 12:36 PM
Listbox Item Focus Kagan Clearwater[_2_] Excel Programming 1 April 5th 07 08:12 PM
listbox add item Baha Excel Programming 0 December 8th 06 02:37 AM
Add item to listbox, but only if it is not already there. Mark Excel Programming 4 September 2nd 05 10:07 PM
The value of a ListBox Item TK Excel Programming 2 August 20th 04 06:17 AM


All times are GMT +1. The time now is 08:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"