How populate multi-column Listbox control?
I don't think Excel's listbox allows that kind of formatting.
And take a look at Chip's suggestion. He builds the array before and just loads
it in one fell swoop.
(And take note of his .columnwidths line, too.)
Robert Crandal wrote:
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.
--
Dave Peterson
|