ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   getting selected listbox values (https://www.excelbanter.com/excel-programming/351599-getting-selected-listbox-values.html)

x taol

getting selected listbox values
 


i set multiselect property of listbox control to fmMultiSelectExtended.
by the way, i want to get the selected list names.
the following code...??

for i = 0 to listbox1.listcount - 1
if listbox1.list(listbox1.listindex).selected then
msgbox listbox1.list(listbox1.listindex)
endif
next

*** Sent via Developersdex http://www.developersdex.com ***

Norman Jones

getting selected listbox values
 
Hi X Taol,

Try:

'=============
Private Sub CommandButton1_Click()
Dim i As Long

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
MsgBox ListBox1.List(i)
End If
Next i

End Sub
'<<=============

---
Regards,
Norman



"x taol" wrote in message
...


i set multiselect property of listbox control to fmMultiSelectExtended.
by the way, i want to get the selected list names.
the following code...??

for i = 0 to listbox1.listcount - 1
if listbox1.list(listbox1.listindex).selected then
msgbox listbox1.list(listbox1.listindex)
endif
next

*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 03:33 PM.

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