I am trying to take selected items from a listbox and put the selected items into an array. Basically I am trying to put the selected items into a variable that I can pass to other modules. I am close but something is off. I can't tell if it's the variable declaration or the code. I've searched the internet and tried many of the options out there but none work for me. I appreciate any insight or help. Perhaps I should be doing something completely different. Thank you.
I get Run Time error 91. Object variable or with block variable not set
Here's what I have so far...
![]()
Dim x as integer Dim i as integer Dim myArray() as variant x = 0 For i = 0 To Me.lstbox1.ListCount - 1 If Me.lstbox1.Selected(i) = True Then ReDim Preserve myArray(x) myArray(x) = lstbox1.List(i) x = x + 1 End If Next i
Bookmarks