Opening User Form with items selected in List Box

S

Stephen English

When I open a User Form with a listbox in fmMultiSelectMulti mode, I want to
be able to select several values based on the list index number
i.e I know i want the first, third and fifth values selected
Anyone know how I do this please?
I have tried frmReport.lstDirections(3).Selected = True

Thanks
Stephen
 
G

Greg Maxey

The following opens a UserForm with A, E, and Z selected in a mulitselect
listbox:

Private Sub UserForm_Initialize()
Dim myArray() As String
myArray = Split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", " ")
Me.ListBox1.List = myArray
Me.ListBox1.MultiSelect = fmMultiSelectMulti
With Me.ListBox1
.Selected(0) = True
.Selected(4) = True
.Selected(25) = True
End With
End Sub
 

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