Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default AddItem with multi-column listBox

Greetings everyone
I'm trying to learn something about list boxes. I have suceeded with loading
a 2 column listBox with a 2 dimensional array but would be interested to know
how to use AddItem. Let's say I just want to load "dog" and "cat" into the
first row of a 2 column list box using AddItem without building an array
first. Please give me some example code
TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default AddItem with multi-column listBox

With ListBox1
.AddItem "dog"
.List(.ListCount - 1, 1) = "cat"
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"David" wrote in message
...
Greetings everyone
I'm trying to learn something about list boxes. I have suceeded with

loading
a 2 column listBox with a 2 dimensional array but would be interested to

know
how to use AddItem. Let's say I just want to load "dog" and "cat" into the
first row of a 2 column list box using AddItem without building an array
first. Please give me some example code
TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default AddItem with multi-column listBox

Listbox1.AddItem "dog"
Listbox1.List(Listbox1.Listcount-1,1) = "cat"

--
Regards,
Tom Ogilvy


"David" wrote in message
...
Greetings everyone
I'm trying to learn something about list boxes. I have suceeded with

loading
a 2 column listBox with a 2 dimensional array but would be interested to

know
how to use AddItem. Let's say I just want to load "dog" and "cat" into the
first row of a 2 column list box using AddItem without building an array
first. Please give me some example code
TIA



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AddItem with multi-column listBox


Hello David,

The AddItem method inserts a single Row into the ListBox. The
ColumnCount property sets the number of Columns. You cna then set the
individual columns using the Column property. The code example shows
how to add the data without creating an Array. You can use the Column
property in your code to get or set a Column Value in a given row.
Remember Line, Column, and Row numbers start at zero.

COLUMN PROPERTY FORMAT:
Column(<-column number-, <-row number-)


CODE EXAMPLE:
With ListBox1
ColumnCount = 2
AddItem
Column(0, 0) = "Cat"
Column(1, 0) = "Dog"
End With


CHANGE A COLUMN VALUE:
ListBox1.Column(1, 0) = "Rat"



Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=479250

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default AddItem with multi-column listBox

Thanks Leith, Bob & Tom,
I've got it now, the 'penny has dropped'
I couldn't see the steps: first add a row, then populate it. I was trying to
populate as part of the AddItem method
Much appreciated
--
David

"Leith Ross" wrote:


Hello David,

The AddItem method inserts a single Row into the ListBox. The
ColumnCount property sets the number of Columns. You cna then set the
individual columns using the Column property. The code example shows
how to add the data without creating an Array. You can use the Column
property in your code to get or set a Column Value in a given row.
Remember Line, Column, and Row numbers start at zero.

COLUMN PROPERTY FORMAT:
Column(<-column number-, <-row number-)


CODE EXAMPLE:
With ListBox1
.ColumnCount = 2
.AddItem
.Column(0, 0) = "Cat"
.Column(1, 0) = "Dog"
End With


CHANGE A COLUMN VALUE:
ListBox1.Column(1, 0) = "Rat"



Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=479250


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
Dynamic Multi Column ListBox Ronbo Excel Programming 3 January 11th 05 07:59 PM
Multi-Column Listbox properties Otto Moehrbach[_6_] Excel Programming 1 December 5th 04 10:35 PM
why can't I additem to multi-column this way.. augustus Excel Programming 4 October 13th 04 04:30 AM
populating a multi-column Listbox Tom Ogilvy Excel Programming 3 April 26th 04 08:26 PM
populating a multi-column Listbox Harald Staff Excel Programming 1 April 26th 04 08:26 PM


All times are GMT +1. The time now is 04:41 AM.

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"