Selecting all entries in a list-box

J

Jonathan Blitz

How can I select/unselect all the entries in a listbox from with VBA code.

I am trying to create select/unselect all buttons.

--
Jonathan Blitz
AnyKey Limited
Israel

"When things seem bad
Don't worry and shout
Just count up the times
Things have worked themselves out."
 
X

Xcelsoft

Jonathan,

You will need to loop through all the items in your
listbox and select or unselect them. See below, this
will select the items in your listbox. To Unselect them,
change True to False. Set the OnClick event to a Command
Button on your form.

Dim intctr As Integer
With Forms!MyForm!MyListBox
For intctr = 0 To .ListCount - 1
.Selected(intctr) = True
Next intctr
End With

Regards,

Xcelsoft
 

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