Jeff Slavin
New Member
Hi All - Have the simple function below to count the number of items selected in a ListBox on a UserForm. For some reason every once in awhile the function will return 0 even though there are items selected in the Listbox.
Any help is greatly appreciated.
Best,
Jeff
Any help is greatly appreciated.
Best,
Jeff
Code:
Public Function MSR_Form_Listbox_GetSelectedCount(lstListBox As MSForms.ListBox) As Integer
Dim i As Integer
Dim iSelected As Integer
iSelected = 0
With lstListBox
For i = 0 To .ListCount - 1
If .Selected(i) = True Then iSelected = iSelected + 1
Next i
End With
MSR_Form_Listbox_GetSelectedCount = iSelected
End Function