Link to home
Start Free TrialLog in
Avatar of BillTr
BillTr

asked on

Selecting multiple items from a listbox

I would like to be able to select multiple items from a listbox and then act on that selection list. Each item selected would initiate separate processing later in my code. I don't do alot with forms and am having trouble finding a good example of that.

Flow:
1. Select multiple items form the list box.
2. If none is selected then assume all items in the box are to be used
3. Read each item to a separate variable and initiate code later on in the script based on the variable.

I imagine that I could read the listbox multiple times for to init the subsequent steps which just consists mainly of importing various data files.
ASKER CERTIFIED SOLUTION
Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think it is unwise to assume that if nothing is selected, everything should be processed.  For listboxes with many items, I usually add two buttons, one for selecting everything and one for deselecting everything.  This is safer.  Here is the code for selecting all -- for deselecting, change True to False:

Set lst = Me![lstSelectMultiple]
intRows = lst.ListCount - 1

For intIndex = 0 To intRows
   lst.Selected(intIndex) = True
Next intIndex

Open in new window