View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default List box with 2 columns

It might be easiest to populate the list box via an array:

Private Sub UserForm_Initialize()
Dim Arr(1 To 2, 1 To 2) As String
Arr(1, 1) = "AAA"
Arr(1, 2) = "111"
Arr(2, 1) = "BBB"
Arr(2, 2) = "222"
ListBox1.List = Arr
End Sub

where ListBox1 has a ColumnCount of at least 2.

Alternatively:

Private Sub UserForm_Initialize()
ListBox1.AddItem "AAA"
ListBox1.AddItem "BBB"
ListBox1.Column(1, 0) = "111"
ListBox1.Column(1, 1) = "222"
End Sub


--
Jim Rech
Excel MVP
"Nath" wrote in message
...
| Hello
|
| I am populating a list box with the field names from a
| recordset from an access database using an Excel form in
| VB. However, i have done the part that populates the
| field names, now i wish to have a 2nd column that contains
| the fields data type. How do i add items, currently i
| have:
|
| userform1.listbox1.additem rst.fields(x).name
|
| i also want to add alond side its name
|
| rst.fields(x).type.
|
| How do i add them so the field name is column 1, and the
| type is column 2.
|
|
| TIA
|
| Nath.