ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Choosing items in a list box (https://www.excelbanter.com/excel-programming/331268-choosing-items-list-box.html)

David Gerstman

Choosing items in a list box
 
I am writing a macro to print timesheets.
In case that the secretary doesn't want to print one out for every person in
the branch I want a userform to select one or individuals.
How do I create a userform with names and corresponding checkboxes so the
user may select individuals to generate the desired time sheets.

Harald Staff

Choosing items in a list box
 
If you can manage with a standard listbox where you select with click, ctrl
click or shift click then try this:

Private Sub UserForm_Initialize()
Dim L As Long
With Me.ListBox1
..MultiSelect = fmMultiSelectExtended
For L = 1 To 20
..AddItem Sheets(1).Cells(L, 1).Value
Next
End With
End Sub

Private Sub CommandButton1_Click()
Dim L As Long
For L = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(L) = True Then _
MsgBox ListBox1.List(L)
Next
End Sub

HTH. Best wishes Harald

"David Gerstman" skrev i melding
...
I am writing a macro to print timesheets.
In case that the secretary doesn't want to print one out for every person

in
the branch I want a userform to select one or individuals.
How do I create a userform with names and corresponding checkboxes so the
user may select individuals to generate the desired time sheets.





All times are GMT +1. The time now is 06:48 PM.

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