View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How populate multi-column Listbox control?

You can use ColumnCount to set the number of columns, ColumnWidths to
set the columns widths and pass an array to List for a list box. E.g.,


Private Sub UserForm_Initialize()
Dim NumRows As Long
Dim NumCols As Long
Dim Arr() As String
NumRows = 2
NumCols = 3
ReDim Arr(1 To NumRows, 1 To NumCols)
Arr(1, 1) = "r1 c1"
Arr(1, 2) = "r1 c2"
Arr(1, 3) = "r1 c3"
Arr(2, 1) = "r2 c1"
Arr(2, 2) = "r2 c2"
Arr(2, 3) = "r2,c3"
With Me.ListBox1
.ColumnCount = 3
.ColumnWidths = "100;30;30"
.List = Arr
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Sat, 6 Mar 2010 13:05:36 -0700, "Robert Crandal"
wrote:

Ok, I'm back with more questions about the Listbox control. The
help documention is not very helpful, so I gotta keep asking here,
haha.

Anyways, my listbox control is set to have 3 columns, but I just can't
figure out how to put data into any column except column 1. How the
heck can I put data in columns 2 or 3???

BTW, I tried the following code which I found through Google, but it
doesn't work:

ListBox1.AddItem "here is some text"
ListBox1.List(1, 1) = "more data"
ListBox1.List(1, 2) = "even more data"

Please help. thank u