Choosing items in a list box

G

Guest

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.
 
H

Harald Staff

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top