CsJHUN
Active Member
- Joined
- Jan 13, 2015
- Messages
- 360
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
- Mobile
Hi guys,
Here is the code which i know of, which loop thru listbox items
Is there any faster way to check if the item is selected? I currently have 4 listbox, with combined 600+ possibilities (all cascade other one until 4th level) and its feels pretty slow.
The code below just checking if anything is selected:
And this is just the warmup part.
I also turned off: app.displayalerts, .screenupdating, .calulcation, .enableevents
Here is the code which i know of, which loop thru listbox items
VBA Code:
for i = 0 to listbox_something.listitems-1
...
next i
Is there any faster way to check if the item is selected? I currently have 4 listbox, with combined 600+ possibilities (all cascade other one until 4th level) and its feels pretty slow.
The code below just checking if anything is selected:
VBA Code:
For i = 0 To box_group.ListCount - 1
If box_group.Selected(i) = True Then group_count = group_count + 1
Next i
For i = 0 To box_one.ListCount - 1
If box_one.Selected(i) = True Then process_count = process_count + 1
Next i
For i = 0 To box_language.ListCount - 1
If box_language.Selected(i) = True Then language_count = language_count + 1
Next i
For i = 0 To box_printitem.ListCount - 1
If box_printitem.Selected(i) = True Then printitem_count = printitem_count + 1
Next i
If printitem_count < 1 Or group_count < 1 Or process_count < 1 Or language_count < 1 Then Exit Sub
I also turned off: app.displayalerts, .screenupdating, .calulcation, .enableevents