Listbox 2

T

Tim Coddington

Ok. So I have this multi-column listbox.
I've figured out how to tell which row is clicked.

Private Sub ListBox1_Click()
MsgBox ListBox1.ListIndex
End Sub

Is there a way to tell which column is clicked?

Thanks,
Tim
 
N

Nigel

Not sure how you are clicking a column, a selection is for the whole row.
You can however access each column of data item by using the List property.
Where List(row,column) can be used.

Sinple procedure to access each column item for the row in the listbox that
is clicked follows.....

Private Sub ListBox1_Click()
Dim ic As Integer
With ListBox1
For ic = 0 To .ColumnCount - 1
Debug.Print .List(.ListIndex, ic)
Next ic
End With
End Sub

Cheers
Nigel
 
B

Bob Phillips

Tim,

You select a row, not a column. You can get at all values in the row like
so

MsgBox "Column 1: " & ListBox1.Value

MsgBox "Column 2: " & ListBox1.List(ListBox1.ListIndex, 1)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

Tim Coddington

Thanks folks, I guess I'll just need to pack to list boxes together and
divine by which list box they choose.
 
Top