NdNoviceHlp
Well-known Member
- Joined
- Nov 9, 2002
- Messages
- 3,834
I would like to limit selections in a multiselect listbox to 2 selections. The third selection should be de-selected(?) following a messagebox indicating the limit. I'm close with the following code but I can't quite get the de-selection part. Any help will be appreciated. Dave
Code:
Private Sub ListBox2_Change()
Dim i As Integer, Cnt As Integer
Cnt = 0
For i = 0 To ListBox2.ListCount - 1
If ListBox2.Selected(i) = True Then
Cnt = Cnt + 1
End If
Next i
If Cnt > 2 Then
MsgBox "Only 2 types can be selected"
'de-select current selection here
End If
End Sub