How to expand selection in listbox

  • Thread starter Thread starter Alejandro
  • Start date Start date
A

Alejandro

There must be a way to select items in a listbox through VBA but I cannot
find it. I want users to allow a selection per listbox item or to click a
button and automatically select all.

Any help would be appreciated.

Alexander
 
Alexander,

Try this:

Ensure your listbox Multiselect is set to Extended or
Simple, then put this into your command button:

Dim i As Integer
For i = 0 To Me.YourListBoxNameGoesHere.ListCount - 1
Me.YourListBoxNameGoesHere.Selected(i) = True
Next i
 
There must be a way to select items in a listbox through VBA but I cannot
find it. I want users to allow a selection per listbox item or to click a
button and automatically select all.


for each chk in lisBox.Selected
chk = True
next chk


Can't remember offhand what datatype the chk object would be -- probably a
boolean -- but it will be in the help files or object browser.

HTH


Tim F
 
There must be a way to select items in a listbox through VBA but I cannot
find it. I want users to allow a selection per listbox item or to click a
button and automatically select all.

Sorry: looking at help files, the Selected() is a property not a
collection: therefore you have

For wCounter = 0 to lisBox.ListCount -1
lisBox.Selected(wCounter) = True

Next wCounter


.... nearly there but no banana!

B Wishes


Tim F
 
Back
Top