Hi all,
I have 10 listboxes in my Userform and want to check if there is at least 1 item selected. I currently use this code, but can this be a loop instead of 10 different pieces of code?
Thanks in advance!
Mathijs.
I have 10 listboxes in my Userform and want to check if there is at least 1 item selected. I currently use this code, but can this be a loop instead of 10 different pieces of code?
Code:
Dim i As Integer
Dim count As Integer
'Categorie
count = 0
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
count = count + 1
End If
Next i
If count = 0 Then
MsgBox ("You have to select at least 1 item!")
Exit Sub
End If
Thanks in advance!
Mathijs.