Select all/Deselect all button in a form

S

Stuart

How can I code a button which will allow the user
to select/deselect all entries in a multiselect listbox,
please?

Currently Textbox1 instructs the user to use the left
mouse button to highlight their chosen sheets,
Listbox1 contains the sheet names, and Command
Button1 = "Click when done".

I'm hoping that when a book contains many sheets,
user could select all then just left click with mouse to
deselect specific sheets.

Is this possible, please?

Regards.
 
R

Rob Bovey

Hi Stuart,

If you set the MultiSelect property of the ListBox to "2 -
fmMultiSelectExtended" then the ListBox will behave like this for you
automatically. Selecting the first item in the list and then holding down
the Shift key while selecting the last item in the list will select all
items in the list. Then holding down the Ctrl key while clicking on specific
list items will unselect them.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
T

Tom Ogilvy

for i = 0 to listbox1.Listcount-1
listbox1.Selected(i) = False
Next

False will unselect. Change to True to select.

Regards,
Tom Ogilvy
 

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