View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_574_] Leith Ross[_574_] is offline
external usenet poster
 
Posts: 1
Default filling userform listbox


Hello Simon,

Here is a method that uses 1 ListBox and a Label on a User Form.
don't think you need a second ListBox if it is only to display data.

When using Columns there are 2 properties that control how the data i
displayed: BoundColumn and TextColumn. BoundColumn controls whic
column is displayed in the ListBox. TextColumn controls which colum
data is returned from.

Set the TextColumn Property of ListBox1 = 2. There are actually
columns of data per line (Row). The user will see only the first colum
and the second will be hidden. When the user clicks on a line, th
Label's Caption will display the second column of the line selected i
ListBox1. Here is the code for the Controls and Events...


Code
-------------------
Private Sub ListBox1_Click()

Label1.Caption = ListBox1.Text

End Sub

Private Sub UserForm_Activate()

With ListBox1
.AddItem
.Column(0, 0) = "A"
.Column(1, 0) = "1,2,3,4"
.AddItem
.Column(0, 1) = "B"
.Column(1, 1) = "X,Y,Z"
End With

End Sub

-------------------


The .AddItem creates a new Row (Line) in the ListBox. The .Column(c, r
places the data in the appropriate Column for that Row. First Row an
Column start at zero.

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=55210