![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I have a ListBox control in my userform. The source would be some cells in my excel sheet. Basically, how do I tell if an entry in the listbox is selected?? Something like.. For all entries in listbox1 if an entry is selected then msgbox entries.value end if end for What's the correct syntax to perform such action? Thanks guys |
|
|
|
#2 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi
I take it you have the MultiSelect Property set to Multi? If so here is some code from a file I am currently working on. Dim UnitsToPrint as Integer Dim bHaveOne as Boolean UnitsToPrint = 0 For i = 0 To UnitListBox.ListCount - 1 If UnitListBox.Selected(i) = True Then iRow = iRow + 1 Sheet20.Cells(iRow, 26) = UnitListBox.List(i) UnitsToPrint = UnitsToPrint + 1 bHaveOne = True End If Next i If bHaveOne = False Then 'No Units selected MsgBox "You have not selected any record(s) to print.", vbCritical, "Nothing to print!" Exit Sub End If |
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hey, Thanks... Really helps
|
|
|
|
#4 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Pleasure!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|