Z
ZipCurs
I am using the following code which activates when the userform is changed.
Private Sub ListBox2_Change()
Dim NumberOfCategories As Integer
Dim PickCount As Integer
NumberOfCategories = Sheets("Parameters").Range("C6") - 1
'Determine the number of items selected
PickCount = 0
For x = 1 To NumberOfCategories
With ListBox2
If .Selected(x) Then
PickCount = PickCount + 1
End If
End With
Next x
'If "ALL" selected turn everything else off ("ALL" is the first line)
If ListBox2.Selected(0) And PickCount > 0 Then
With ListBox2
For x = 1 To NumberOfCategories
.Selected(x) = 0
Next x
End With
End If
I have 2 problems. The code the count the number of items selected fails at
x=2. More importantly the "ALL" code causes the code to loop continuously.
Is there a way to set the change event to false at the bottom of the code to
prevent continuous looping? What other option do I have? Thank you in
advance.
Private Sub ListBox2_Change()
Dim NumberOfCategories As Integer
Dim PickCount As Integer
NumberOfCategories = Sheets("Parameters").Range("C6") - 1
'Determine the number of items selected
PickCount = 0
For x = 1 To NumberOfCategories
With ListBox2
If .Selected(x) Then
PickCount = PickCount + 1
End If
End With
Next x
'If "ALL" selected turn everything else off ("ALL" is the first line)
If ListBox2.Selected(0) And PickCount > 0 Then
With ListBox2
For x = 1 To NumberOfCategories
.Selected(x) = 0
Next x
End With
End If
I have 2 problems. The code the count the number of items selected fails at
x=2. More importantly the "ALL" code causes the code to loop continuously.
Is there a way to set the change event to false at the bottom of the code to
prevent continuous looping? What other option do I have? Thank you in
advance.