I wanted my listbox to be in my userform. However when I try to code it in the way that makes sense to me I keep throwing this error, "The item with the specified name wasn't found." And highlights:
Call UserForm1.ListBoxFunction(ar())
This is the part from the module:
Function calluserform(ar() As String)
Call UserForm1.ListBoxFunction
End Function
This is the part from the userform:
Function ListBoxFunction(ar() As String)
Dim Count As Integer, i As Integer, j As Integer, n As Integer
Dim SummaryWks As Worksheet
Dim LB As ListBox
Set SummaryWks = Worksheets("Summary")
Set LB = SummaryWks.OLEObjects("TowerTypeLB").Object
Count = 0
n = 3
For i = 0 To LB.ListCount - 1
'check if the row is selected and add to count
If LB.Selected(i) Then Count = Count + 1
Next i
'based on the above count declare the array
ReDim ar(Count)
j = 0
For i = 0 To LB.ListCount - 1
If LB.Selected(i) Then
'if selected then store the item from the
'first column in the array. change 1 to the
'respective column number
ar(j) = LB.List(i)
j = j + 1
End If
Next i
End Function
Bookmarks