This has been driving me a little crazy -
I have a List Box on the a worksheet called MyListBox, the List Box is populated with data from a range. The List Box is multi select.
I want to use the following to get the selected items:
Private Sub MyListBox()
Dim lb As ListBox
Dim i As Long, temp
Set lb = Sheets("Sheet1").ListBoxes(1)
With lb
For i = 0 To .ListCount
If .Selected(i) Then
temp = temp & i & " " & .List(i) & Chr(10)
End If
Next i
End With
MsgBox "Selected items were:" & Chr(10) & temp
End Sub
The problem is that I don't think I can use Selected with ListBox objects. I've tried across Excel 2010 (PC) and Mac (2011). I need to use Form Control elements as the sheet has to be shared between Mac + PC users.
Any ideas as to how to get the selected items?
Is the documentation really as bad as I think it is? Normally I would go to a docs page and just look up the methods for an object, but there's just nothing!
Thanks -