Select all in Listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

What code would I use in the Form Open Event to by default have all the
items in a list box selected?

Thanks,

Daniel
 
Private Sub Form_Load()
Dim lng As Long

With Me.[NameOfYourListBoxHere]
For lng = 0 To .ListCount - 1
.Selected(lng) = True
Next
End With
End Sub
 
Thank you so very much!

Allen Browne said:
Private Sub Form_Load()
Dim lng As Long

With Me.[NameOfYourListBoxHere]
For lng = 0 To .ListCount - 1
.Selected(lng) = True
Next
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Daniel said:
Hello,

What code would I use in the Form Open Event to by default have all the
items in a list box selected?

Thanks,

Daniel
 
Back
Top