Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Feb 2009
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For form control, list box (single selection type), I use macro code: x = Sheets(2).Shapes("List Box 8").ControlFormat.ListIndex
    to get which item has been selected by the user.

    However, for form control, list box (mult selection type), you can not use ListIndex property (works for single selection type only).
    Then, what is the property (code) for knowing which items in the list box (mult selection type) have been selected?

    I'm thinking its something along the lines of:
    For Each Item In Sheets(2).Shapes("List Box 8").ControlFormat.List
    If item [.something = something] Then x = item (or add to array if more than one item selected)
    Next Item

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can use

    Code:
    Dim i As Integer
    With Sheets(2).ListBoxes("List Box 8")
      For i = 1 To .ListCount
    	If .Selected(i) Then
    	  Debug.Print "Item " & i & " has been selected"
    	End If
      Next i
    End With

  3. #3
    Lounger
    Join Date
    Feb 2009
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='santford' post='787951' date='07-Aug-2009 17:26']For form control, list box (single selection type), I use macro code: x = Sheets(2).Shapes("List Box 8").ControlFormat.ListIndex
    to get which item has been selected by the user.

    However, for form control, list box (mult selection type), you can not use ListIndex property (works for single selection type only).
    Then, what is the property (code) for knowing which items in the list box (mult selection type) have been selected?

    I'm thinking its something along the lines of:
    For Each Item In Sheets(2).Shapes("List Box 8").ControlFormat.List
    If item [.something = something] Then x = item (or add to array if more than one item selected)
    Next Item[/quote]
    Thanks Hans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •