0
I have a list ListBox1
q a check box ChckBox1
in a Userform. I want to activate or inactivate the checkbox (CheckBox1.Enabled = True/False
if an item in the list is selected.
The check-box is disabled initially, but if something is selected, I want it to be enabled for marking.
At the moment I am using a loop for validation, but I would like to know if there is a more direct way, without having to analyze item by item.
Private Sub ListBox1_Change()
Dim s As Boolean: s = False
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
s = True
Exit For
End If
Next i
CheckBox1.Enabled = s
End Sub