View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal Robert Crandal is offline
external usenet poster
 
Posts: 309
Default How populate multi-column Listbox control?

Dave,

Thanks, that worked great!

BTW, do you know if I can add gridlines or something to the listbox
so I can see the dimensions of each cell in the listbox?? I almost might
want column 3 to be longer than the others.

Thanks again!

"Dave Peterson" wrote in message
...
When I do this kind of thing, I'm usually looping through something.

So...

Option Explicit
Private Sub UserForm_Initialize()
Dim iCtr As Long

With Me.ListBox1
.Clear
.RowSource = ""
.ColumnCount = 3

For iCtr = 1 To 5
.AddItem "A" & iCtr
.List(.ListCount - 1, 1) = "B" & iCtr
.List(.ListCount - 1, 2) = "C" & iCtr
Next iCtr
End With
End Sub

Listcount is how many items there are (1 then 2, then 3, ..., then 5 in
this
case), but the first item in the list is item 0, so we subtract 1 from the
current listcount.