ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox 2 (https://www.excelbanter.com/excel-programming/303768-listbox-2-a.html)

Tim Coddington

Listbox 2
 
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



Nigel

Listbox 2
 
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

"Tim Coddington" wrote in message
...
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





Bob Phillips[_6_]

Listbox 2
 
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)

"Tim Coddington" wrote in message
...
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





Tim Coddington

Thanks Listbox 2
 
Thanks folks, I guess I'll just need to pack to list boxes together and
divine by which list box they choose.
"Bob Phillips" wrote in message
...
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)

"Tim Coddington" wrote in message
...
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








All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com